填空题

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

【参考答案】

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

填空题
下列程序的输出结果是______。 #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;
填空题
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream.h> using namespace std; class Base public: int a,b; Base(int i)a=i; ; class Derived:public Base int a; public: Derived(int x):Base(x),b(x+1); void show() ______; 输出基类数据成员a的值。 cout<<b<<endl; ; void main() Derived d(1); d.show(); return 0;
相关试题
  • 有如下类定义: class Foo public: Fo...
  • 有以下程序: #include<iostream> usi...
  • 下列程序的运行结果是( )。 #include...
  • 下面程序的运行结果为( )。 #include...
  • 有以下程序: #include<iostream> usi...