当自己没有定义类的析构函数时,编译器会自动生成析构函数,不过,这个析构函数是非虚函数,当一个基类的析构函数是编译器生成时,容易发生问题。
输出为
Base construct
Derived construct
输出为
Base construct
Derived construct
Derived destruct
Base destruct
当自己没有定义类的析构函数时,编译器会自动生成析构函数,不过,这个析构函数是非虚函数,当一个基类的析构函数是编译器生成时,容易发生问题。
输出为
Base construct
Derived construct
输出为
Base construct
Derived construct
Derived destruct
Base destruct