C++构造函数的三种调用方法
1、拷贝参数传递,
void test01() {
Point p = Point(2, 3);
cout << "p.x=" << p.x << endl;
cout << "p.y=" << p.y << endl;
cout << "p.地址:" << (int*)&p << endl;
Point p1 = Point(p);
cout << "p1.x=" << p.x << endl;
cout << "p1.y=" << p.y << endl;
cout << "p1.地址:" << (int*)&p1 << endl;
}
构造函数
p.x=2
p.y=3
p.地址:012FFADC
拷贝函数:
p1.x=2
p1.y=3
p1.地址:012FFAC0
析构函数!!!!
析构函数!!!!