Note: in a derived class, if your base class has a virtual destructor, your own destructor is automatically virtual. You might need an explicit destructor for other reasons, but there's no need to redeclare a destructor simply to make sure it is virtual. No matter whether you declare it with the virtual keyword, declare it without the virtual keyword, or don't declare it at all, it's still virtual.
【在 e******0 的大作中提到】 : 不行, base 定义了 析构函数是virtual, : derived必须也定义析构函数是virtual
l*s
7 楼
没开包的可以放久一点吧?
c*s
8 楼
can't agree more...
your destructor the declare
【在 c****o 的大作中提到】 : Note: in a derived class, if your base class has a virtual destructor, your : own destructor is automatically virtual. You might need an explicit : destructor for other reasons, but there's no need to redeclare a destructor : simply to make sure it is virtual. No matter whether you declare it with the : virtual keyword, declare it without the virtual keyword, or don't declare : it at all, it's still virtual.