构造析构顺序
#include <iostream>
class Person
{
public:
Person()
{
std::cout << "Person" << std::endl;
}
~Person()
{
std::cout << "~Person" << std::endl;
}
private:
};
class Student: public Person
{
public:
Student()
{
std::cout << "Student" << std::endl;
}
~Student()
{
std::cout << "~Student" << std::endl;
}
};
int main()
{
Student s;
return 0;
}
$ ./a.out
Person
Student
~Student
~Person