+ 1
Why can't it print the value from the address directly?
If: int x = 10; // declares variable x int* p = &x; // declares variable p and assigns the address of x cout << p << endl; // prints: 0x23fe44 cout << *0x23fe44 << endl; Why does the line above not work? Isn't it the same as the line below? cout << *p << endl;
4 odpowiedzi
+ 1
Thanks! Undertand pointer clearer now.
+ 1
pointer is a data type that can store an address.
* is a function of that datatype that allows access of the data at the address.
The address itself hasn't got that 'access me' button.