填空题
在MyClass类的定义中,对赋值运算符;进行重载。请将横线处缺失的部分补充完整。
______MyClass::operator=(const MyClass& rhs)
if(this == &rhs) return *this;
value = rhs.value;
return *this;
【参考答案】
MyClass&
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
在下列的程序的横线处填上适当的语句,使该程序的输出为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;
点击查看答案&解析
填空题
下列程序的输出结果为2,请将程序补充完整。 #include <iostream> using namespace std; class Base public: ______void fun() cout<<1; ; class Derived:public Base public: void fun()cout<<2; ; int main() Base*p=new Derived; p->fun(); delete p; return 0;
点击查看答案&解析
相关试题
有如下程序: #include <iostream> u...
如下类定义中包含了构造函数和拷贝构造函数...