填空题

在MyClass类的定义中,对赋值运算符=进行重载。请将横线处缺失的部分补充完整。
______MyClass::operator=(const MyClass&rhs)

if(this==&rhs)return*this;
value=rhs.value;
return*this;

【参考答案】

MyClass&。
<上一题 目录 下一题>
热门 试题

填空题
有以下程序: #include<iostream> using namespace std; class Base public: Base() K=0; int x; ; class Derivedl:virtual public Base public: Derivedl() x=10; ; class Derived2:virtua1 public Base public: Derived2() x=20; ; class Derived;public Derivedl,protected Derived2 ; int main() Derived obj; cout<<obj.x<<endl; return 0; 该程序运行后的输出结果是______。
填空题
下列程序的输出结果是______。 #include<iostream) using namespace Std; Class Test public: Test()cnt++; ~Test()cnt--; staticint Count()return cnt; private: static int cnt; ; int Test::cnt=0; int main() cout<<Test::Count()<<‘‘; Test t1,t2; Test*pT3=new Test; Test*pT4=new Test; cout<<Test::Count()<<‘‘; delete pT4; delete pT3; cout<<Test::Count()<<endl; return 0;
相关试题
  • C++语句constchar *constp=”hello”...