I am confused about virtual destructor. I know if we create instance of derived class using a base class pointer like the following
Base *p = new Derived;
But if we delete this now
delete p;
Why would it not delete the object properly? What is p
pointing towards ? I know that making the base class destructor virtual would kill the object properly but how does this thing conceptually work ? It has something to do with heap ? As a result of the statement
Base *p = new Derived;
What is being stored in the stack and what's on the heap ? And by simply deleting (with non virtual base destructor) why it's not calling the derived destructor. I'm just confused conceptually.