Possible Duplicate:
Pure virtual destructor in C++
class A{
public:
virtual ~A()=0;
};
class B:public A{
int *i;
public:
~B() {delete i;}
};
int main(){
B* temp = new B;
}
I’m just trying to have B be an implementation of A. For some reason I cannot do this.
In C++ destructor can be pure virtual:
But in every case it needs to be implemented:
Otherwise A is not usable class. I mean destruction of derived (S/B) is not possible. And possibility of destruction is needed in this line:
because in case of throwed exception – compiler will automatically destructs temp…