0

How can I check if CPoint (or any other) variable has been initialized?
I'm getting error for this:

if(m_pointVar != NULL)

saying binary '!=' : no operator defined which takes a left-hand operand of type 'class CPoint'

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by duka96
0

m_pointVar has to be a pointer for that to work. If it isn't, then how to check will depend on the class. Make the class constructor initialize all its variables and the program user won't have to worry about whether it was initialized or not.

Testing for NULL pointer will not even tell you whether the pointer is valid or not. It might be an uninitialized pointer or a pointer that was deleted.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.