L Lê Như Ý New member Sep 18, 2021 #1 What will be the output of the following C++ code? Code: #include <iostream> using namespace std; int main() { int n = 5; void *p = &n; int *pi = static_cast<int*>(p); cout << *pi << endl; return 0; } A. 5 B. 6 C. compile time error D. runtime error
What will be the output of the following C++ code? Code: #include <iostream> using namespace std; int main() { int n = 5; void *p = &n; int *pi = static_cast<int*>(p); cout << *pi << endl; return 0; } A. 5 B. 6 C. compile time error D. runtime error
Nguyễn Hồng Yến New member Sep 18, 2021 #2 Answer: a Explanation: We just casted this from void to int, so it prints 5 Output: Code: $ g++ poi1.cpp $ a.out 5 Upvote 0 Downvote
Answer: a Explanation: We just casted this from void to int, so it prints 5 Output: Code: $ g++ poi1.cpp $ a.out 5