标签:aaa include 派生 virt col turn span pac bbb
#include <iostream> using namespace std; class A{ public: A() { cout<<"construct A"<<endl; } virtual void disp() { cout<<"AAAA"<<endl; } ~A() { cout<<"destory A"<<endl; } }; class B:public A { public: B() { cout<<"construct B"<<endl; } virtual void disp(int a) { cout<<"BBBB"<<endl; } ~B() { cout<<"destory B"<<endl; } }; int main() { A *a=new A(); B *b=new B(); delete b; return 0; }
析构函数:
构造顺序:
1. 先构造基类,再构造派生类
析构顺序:(与构造相反)
1. 先析构派生类,再析构基类
标签:aaa include 派生 virt col turn span pac bbb
原文地址:http://www.cnblogs.com/hertzz/p/7648153.html