继承类的构造析构顺序
构造: 现有父类后有子类
析构:和构造顺序相反,先析构子类后析构父类
#include <iostream> class A { public: A() { std::cout << "ctor father" << std::endl; } virtual ~A() { std::cout << "dtor fathor" << std::endl; } }; class a : public A { public: a() { std::cout << "ctor son" << std::endl; } ~a() { std::cout << "dtor son" << std::endl; } }; int main(void) { a aa; return 0; }
无情的摸鱼机器