You will have to fix the compiler errors first.
Since you are writing C++, include <iostream> and use std::cout to print to the screen, instead of using printf.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
In the second line you take a pointer to the object a by preceding the variable with an ampersand. In the third line you take a pointer to the object b. Since b has type int*, &b has type int** (pointer to pointer to int). If instead you want to take get the value of what b points to, use *b.
Also, here
Code:
cout<<b;
you are printing the value of b, i.e. the memory address it is pointing to. You can get the value of what b is pointing to in the same way as above.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
I could, but I generally don't do that since I don't believe it will help you. If you want to see an example then search for one online and you'll find plenty. Then again, I can't imagine that the book you are studying (or your teacher) didn't provide any examples that show how to dereference a pointer. Reapplying that knowledge in another situation is what learning is all about. If you just copy a piece of code written by someone else, you have learned nothing - and that will come to haunt you for sure.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Bookmarks