Consider
class A
{
public:
virtual void foo () = 0;
};
At this point it is absolutely obvious that A
is an abstract class and will never be instantiated on it's own. So why the standard doesn't demand that automatically generated destructor must be virtual as well?
I ask myself this question every time I need to define a dummy virtual desctuctor in my interface classes and can't see why the commetee did't do this.
So the question: why generated destructor in an abstract class is not virtual?
void f(Base*p); void x() { Derived d; f(&d); }
is perfectly okay as long asf
doesn'tdelete p;
. – Chaconnef
doesn'tdelete p;
, you know thatp
must be deleted sooner or later by your program, otherwise there would be a memory leak since you don'tdelete
it. How do you think about it? – Gregoire