I don't understand why the out put is: 98 98
98 98
When was x and y ever initialized?
Code is:
int x;
int y;
int *p = &x;
int *q = 98;
int*p = *q;
cout << x << " " << y << endl;
cout << *p << " " << *q << endl;
Sorry, output is
98 98
98 98
what are you trying to get your output to be?
The output is
98 98
98 98
I just don't understand why. It's an example from my book
Last edited on
It's true the code didn't compile. Either it was a simple typing error, or the book is pretty bad.