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

What's the point?
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
Topic archived. No new replies allowed.