构造函数;调用对象前调用,用于初始化对象;
//析构函数;销毁对象前调用,用于清理对象;
#include<iostream>
#include<string>
using namespace std;
class Person
{
public:
//构造函数;调用对象前调用,用于初始化对象;
Person()
{
cout << "Person 构造函数" << endl;
}
//析构函数;销毁对象前调用,用于清理对象;
~Person()
{
cout << "Person的析构函数" << endl;
}
};
int main()
{
Person p;
system("pause");
return 0;
}