Fabio's notes
Some notes (mainly linux related)
Wednesday, March 28, 2012
virtual destructor
#include <iostream>
struct A{
virtual void f()=0;
};
struct B:public A{
void f(){}
~B(){
std::cout<<"~B"<<std::endl;
}
};
int main(){
A* a=new B();
delete a;
}
does not print ~B.
it NEEDS virtual ~A(){}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment