c++ - Scalar deleting destructor -
i have piece of code (from dll) looks this:
class { public: virtual ~a(); }; class b : public { public: ~b(); } ~a() { // #1 } ~b() { // #2 }
when use delete an_instance_of_b
scalar deleting destructor
. workarounds?
don't delete
instance of b
. you're supposed use delete
on pointers object allocated new
:
b b; delete b; //wrong //......... b* pb = new pb; delete pb; //okay //......... b justthis; //best
Comments
Post a Comment