In below code snippet, although pointer is not initialized the call is still made successfully
temp *ptr; ptr->func2();
Is it due to C++
I suspect that ptr->func2() is optimised away as it always returns true. But as Richie says, the use of the pointer is fine in this case as you;re not touching any instance data (a) and as such there is nothing to crash into.
ptr->func2()