Its me again , now came with a NULL pointer in hand... You may think what so special about NULL pointer , right ? .
it is very special . for example even if multiply two NULL pointers ,you will get a the result as a NULL pointer.. is it interesting ? .. :) I was just joking..
I wrote this beacause mostly people checks in destructor something like this
if(p) delete p;
This is not needed , you can just avoid that checking, because delete NULL , will not cause any probles.
so if you have more pointers in your class to delete , avoid that checking is too good to see.
I think Now it is good to mention about this function IsBadWritePtr . This function can be used to checkwhether one address is good to write. In MFC there is function AfxIsValidAddress which will call this function to check.
CCLemon *p = NULL;
Still this will works . but only one condition , Drink should not access any member variables of class CCLemon , and Drink shouldn't be a virtual function. If Drink is a virtual function result is Bhooommm!!!