I would like to know what is going on inside and its relation to the displayed values. Code:
# include <iostream>
int main(){
using namespace std;
const int a = 10;
int* p = &a;
cout << &a <<"\t" << p <<endl;
cout << a << "\t" << *p << endl;
*p = 11;
cout << &a <<"\t" << p <<endl;
cout << a << "\t" << *p << endl;
return 0;
}
QUESTION: If p = address-of-a, how did you get a = 10, but * p = (goto address a and read in the memory location) = 11?
source
share