It's not the same at all. The two are very different.
In the first example... you have one integer (a). You then create a pointer (b) which points to a. When you print *b... the * tells it to "dereference" the pointer, which basically means to go get whatever variable b points to. So by printing *b, you are printing the variable pointed to by b, which in this case is a. So you print a.
In the second example, you create two separate integers (a and b). Then assign b so that it contains the same value as a. Then you print b (instead of printing a as you are in the first example).
try this to see what I mean:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int a = 25;
int* b = &a;
a = 5; // <- a is now 5
cout << *b << endl; // <- prints "5"
int a = 25;
int b = a;
a = 5;
cout << b << endl; // <- prints "25"
What still sort of confuses me is cout << *b << endl;
I get the concept, but I don't get the function of the asterisk in front of the 'b'...
It's kind of hard to explain... Urg... pointers are confusing...
In the picture, it says "print what 'b' points to... which is a," but wouldn't
'b' be pointing to '&a' instead of just 'a' because of int* b = &a;
hopefully a better way of explaining it...?
I would have thought that using the 'p' for pointer variables, might make the understanding easier for newbies. Confusion for newbies comes from 'a' being an int, 'b' being a pointer to int, then 'b' is assigned the address of 'a'. It makes sense to those who understand, but I am saying it might be easier if the pointer variables had the leading 'p', and the variable names were words.
HN is not that bad, as long as one doesn't get carried away with it. I have seen lots of code which uses p for pointers. As for the classes, Qt uses Q, and KDE uses K.
Where HN is bad, is when it is the meaning isn't clear. If it is restricted to just pointers & classes say - then I don't see it as being a problem. The meaning of the notation should be obvious at declaration, but the main responsibility for meaning still lies with the name of the variable.