[try Beta version]
Not logged in

 
 
int *myPointer = 0 (What's the point of this pointer?)

Jun 5, 2013 at 11:22pm
What's the point?
Jun 5, 2013 at 11:32pm
It's a way to initialize a pointer so that it doesn't contain junk (and so you don't try to access memory that's not allocated for your program).

If you don't give it a value, it will have whatever value was in the memory before it. In C++11, a keyword "nullptr" was added:

int* myPointer = nullptr;

This just means it points to nothing.

More here: http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.html
Last edited on Jun 5, 2013 at 11:37pm
Topic archived. No new replies allowed.