Calling class method through NULL class pointer [duplicate]

Calling member functions using a pointer that does not point to a valid object results in undefined behavior. Anything could happen. It could run; it could crash.

In this case, it appears to work because the this pointer, which does not point to a valid object, is not used in print.

Leave a Comment