#include <iostream>
using namespace std;
class person {
public:
person() {
cout << "person的无参构造函数的调用" << endl;
}
person(int a) {
age = a;
cout << "person的有参构造函数的调用" << endl;
}
person(const person &p) {
age = p.age;
cout << "person的拷贝构造函数的调用" << endl;
}
~person() {
cout << "person的析构函数的调用" << endl;
}
int age;
};
void test1() {
/*括号法*/
person p;
person p2(10);
person p3(p2);
/*显示法*/
person p1;
person p4 = person(10);
person p5 = person(p2);
/*隐式转换法*/
person p6 = 10;
person p7 = p4;
}
int main() {
test1();
system("pause");
return 0;
}