1)基类的构造函数。
2)成员对象构造函数。
3)派生类本身的构造函数。
记忆方式:先父母,再客人,后自己。
cpp
#include <iostream>
#include <thread>
#include <string>
#include <iostream>
using namespace std;
class AAA {
public:
AAA() { cout<<"AAA"<<endl;}
~AAA(){}
};
class CCC {
public:
CCC() { cout<<"CCC"<<endl;}
~CCC() {}
};
class BBB :public AAA{
public:
BBB() { cout<<"BBB"<<endl;}
~BBB() {}
private:
CCC c;
};
int main()
{
BBB *b = new BBB;
delete b;
return 0;
}