Sometimes you might be doing something where you're not sure if the pointer is actually pointing to anything. The answer isn't that different than what you would do in Pascal, really. There's a constant, called NULL, which is assigned to pointers to mean that they don't point anywhere. You may remember Pascal's version of NULL, nil. There really isn't any difference between the two. Here's an example of a check you might do in the middle of a program: if (taco != NULL) cout << "I feel like I could eat " << *taco << " tacos!" << endl; |