#include<iostream>
#include<string>
using namespace std;
class Base {
public:
Base()
{
cout << "调用了父类的构造函数" << endl;
}
~Base()
{
cout << "调用了父类的析构函数" << endl;
}
};
class Son :public Base
{
public:
Son()
{
cout << "调用了子类的构造函数" << endl;
}
~Son()
{
cout << "调用了子类的析构函数" << endl;
}
};
void test01()
{
Son s;//创建子类对象时,自动调用构造和析构
}
int main()
{
test01();
}