This book I'm following gives questions but no answers which is strange but this is one of them.
"Will the three memory addresses displayed by the program be the same? Explain what's going on in the program."
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main() {
int a = 10;
int& b = a;
int* c = &b;
cout << &a << endl;
cout << &b << endl;
cout << &(*c) << endl;
return 0;
}
Now I know the memory addresses will be the same. So first an integer variable named "a" is declared then initialized to 10.
"b" is declared as a reference type and refers to the object value held by "a".
Lastly an integer pointer is declared named "c" which points to the memory address of the object "b" refers to which is the memory address of the object value stored in "a".
I don't know. Unlike in jumping into c++ where the answers are at the end pages, it doesn't have answers.
But i switched from jumping into to c++ to beginning c++ through game programming.