What will happen when I call a member function on a NULL object pointer? [duplicate]

It’s undefined behavior, so anything might happen.

A possible result would be that it just prints "fun" since the method doesn’t access any member variables of the object it is called on (the memory where the object supposedly lives doesn’t need to be accessed, so access violations don’t necessarily occur).

Leave a Comment