问题
填空题
在TestClass类的定义中,对赋值运算符=进行重载。请将画线处缺失的部分补充完整。______TestClass::operator=(const TestClass& rhs)
if(this==&rhs)return *this;
value=rhs.value;
return *this;
答案
参考答案:TestClass&
解析: 如果要重载一个类的运算符=,通常需要定义自己特有的拷贝构造函数。在类体中可以增加:(const & operator lestClass & rhs);然后在TestClass的类体外给出它的完整定义:
TestClass& TestClass::operator=(const TestClass& rhs)
{…