destructor on pointer of parent class
-
is this wrong? if yes, how bad is it? class B extends class A. each has a virtual destructor.
A* a = new B();
delete a;by how bad I mean is the loss only in form of memory leak or could this lead to memory corruption?
-
is this wrong? if yes, how bad is it? class B extends class A. each has a virtual destructor.
A* a = new B();
delete a;by how bad I mean is the loss only in form of memory leak or could this lead to memory corruption?
-
is this wrong? if yes, how bad is it? class B extends class A. each has a virtual destructor.
A* a = new B();
delete a;by how bad I mean is the loss only in form of memory leak or could this lead to memory corruption?
-
No, it's fine. In this case, B's destructor doesn't have to be virtual; only the base class needs to be.
Best, Jun
thanks both of you, got the point. makes me wonder how people would have managed to code if there was no dynamic dispatch. :)