BaseClass * p = new DerivedClass();
delete p;
I know the 2nd line will call the destructor of the base class if it doesn't have a virtual destructor and that of the derived class if it does but will delete
properly free the memory (let's say BaseClass
's object takes up 8 bytes of space and DerivedClass
's one 12 - will it free 8 or 12 bytes) and get rid of the object in either case?
malloc
/free
semantics? – Finegrain