Your program exhibits undefined behavior. "Seems to work" is one possible manifestation of undefined behavior. It's morally equivalent to
Thing* p = NULL;
p->DoStuff();
which I predict would also compile and run. DoStuff
is called with NULL
for this
pointer - but it doesn't actually use this
, that's why it doesn't crash and burn as you expect.