填空题
有些运算符既可以作为成员函数重载,也可以作为非成员函数重载。若在一个重载的运算符函数的定义中成功地使用了this指针,说明它是作为【13】重载的。
【参考答案】
成员函数
点击查看答案
<上一题
目录
下一题>
热门
试题
填空题
有下列程序的输出结果是2334,请将横线处缺失部分补充完整。#includeusing namespace std;class Base{int m;pubic;Base(int k):m(k){}int getM()const{return m;}}class Derived:public Base{int n;public;Derived(int k):【11】,n(k){}int getN()const{return n;}}int main(){Derived d1(3),d2(4);cout<<d1.getM()<<d1.getN<<d2.getM()<<D2.getN();return 0;}
点击查看答案
填空题
若下列程序的输出结果是20,请将横线处缺失部分补充完整。#includeusing namespace std;class MyClass{pubic;MyClass(int x=)10:value(x){}void SetValue(int x){value=x;cout<<x;}private;int value;};int main(){MyClass*ptr=new MyClass;【10】 通过对象指针ptr调用SetValue函数delete ptr;return 0;}
点击查看答案
相关试题
有如下程序:#includeusing namespace s...
有如下程序:#includeusing namespace s...
在C++中,编译时的多态性是通过模板或函...