Pointer

What is different between &ptr and ptr that both are Hex?
I know ptr is memory address. what about &ptr?

1
2
3
4
5
6
int main(){
int *ptr;
ptr = new int;
*ptr = 9;
cout << &ptr << endl << ptr ;
}
There are four two main concepts you have to understand clearly
1. Normal variable
2. Pointer variable

The "*" oparend helps a variable to become unique from normal var.. Suppose "*p" is a pointer var then "*p" define its value whether "p" defines its mem address.. It doesnt need "&"
But suppose "i" is a normal var then it will need "&" for defining its memory

In a word this "&" is for normal var, not for pointer var...
Topic archived. No new replies allowed.