Tuesday, April 09, 2002

Pointers in C++



Pointers in C++ are a major conceptual stumblingblock. Lippman's book was very confusing on this. And even Bruce Eckel left me confused. My third resource, C language tutorial, by Juan SouliƩ finally gets it right explaining C++ pointers.





This following simple paragraph made all the difference in the world clarifiying the declaration of a pointer [e.g. int * mypointervariable ] versus using a pointer variable to access the value of the variable being pointed to [e.g. variable2 = *mypointervariable] or loading an address into a pointer variable [e.g. mypointervariable = &addressOfVariable] made all the difference in the world!



I emphasize that this asterisk (*) that we put when declaring a pointer means only that: that it is a pointer, and does not have to be confused with the reference operator that we have seen a bit earlier and that is also written with an asterisk (*). They are simply two different tasks represented with the same sign.





Thanks Juan SouliƩ!



0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home