let's say I define a pointer variable to be of some class type ptrClass:
ptrClass *ptr;
and let's say this ptrClass
has a member function called get()
that returns a pointer that is pointing to nothing.
so if we do:
ptr->get();
this would result in a seg fault.
but if we do if(ptr->get())
, this does not result in a seg fault (the if statement simply does not execute). Can someone explain why this is the case? In order to check the if statement condition, doesn't the program perform ptr->get()
, which should result in seg fault?