z****e 发帖数: 2024 | 1 请问,virtual dtor 以后,下面派生子类,派生子类的派生子类,子子孙孙,他们的
dtor都自动virtual 了么?
还是,无论当前类的基类是不是有virtual dtor,只要从当前类,想派生子类,必须把
当前类的dtor显示声明为virtual?
早谢。 | p***o 发帖数: 1252 | 2
Yes.
Not always. See C++ Coding Standards by Herb Sutter and Andrei Alexandrescu,
item 50, Make base class destructors public and virtual, or protected and
nonvirtual.
【在 z****e 的大作中提到】 : 请问,virtual dtor 以后,下面派生子类,派生子类的派生子类,子子孙孙,他们的 : dtor都自动virtual 了么? : 还是,无论当前类的基类是不是有virtual dtor,只要从当前类,想派生子类,必须把 : 当前类的dtor显示声明为virtual? : 早谢。
| z****e 发帖数: 2024 | 3 好的。
Alexandrescu,
【在 p***o 的大作中提到】 : : Yes. : Not always. See C++ Coding Standards by Herb Sutter and Andrei Alexandrescu, : item 50, Make base class destructors public and virtual, or protected and : nonvirtual.
|
|