C++构造函数问题17

null

#include<iostream>
using namespace std;
class Test
{
public :
Test(Test &t) { }
Test()        { }
};
Test fun()
{
cout << "fun() Called" ;
Test t;
return t;
}
int main()
{
Test t1;
Test t2 = fun();
return 0;
}


(A) fun()打电话来 (B) 空输出 (C) 编译器错误:因为复制构造函数参数是非常量 答复: (C) 说明: 详情见下文:

为什么复制构造函数参数应该是C++中的常数? 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享