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'

Recommended Answers

All 2 Replies

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.

Ok, thanks, I'll try to do it with pointer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.