关于考贝构造函数
class Test
{
public:
Test()
{
cout << "constructor "<< endl;
}
~Test ()
{
cout << "destructor "<< endl;
}
Test (Test & p)
{
cout << "copy constructor "<< endl;
}
};
Test fun(Test C)
{
return C;
}
void main()
{
Test C1;
fun(C1);
system("pause");
return ;
}
拷贝构造函数调用:
1. 一个对象以值传递的方式传入函数体
2. 一个对象以值传递的方式从函数返回
3. 一个对象要通过另一个对象进行初始化。