单项选择题
有如下类定义和变量定义:
class A
public:
A( )data=0;
~A( )
int GetData( )constreturn data;
void SetData(int n)data=n;
private:
int data;
;
const A a;
A b;
下列函数调用中错误的是
A.GetData( );
B.SetData(10);
C.GetData( );
D.SetData(10);
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下类定义: class XX int xx; public: XX( ):xx(0)eout<<’A’; XX(int n):xx(n)tout<<’B’; ; class YY:public XX mt yy; public: YY( ):yy(0)i cout<<yy; YY(int n):XX(n+1),yy(n)cout<<yy; YY(int m,int n):XX(in),yy(n)cout<<yy; ; 下列选项中,输出结果为A0的语句是
A.YY y1(0,0);
B.YY y2(1);
C.YY y3(0);
D.YY y4;
点击查看答案&解析
单项选择题
有如下程序: #include<iostream> using namespaee std; class Pair int m; int n; public: Pair(int i,int j):m(i),n(j) boot operator>(pair P)const; 需在类体外给出定义 ; int main( ) Pair pl(3,4),p2(4,3),p3(4,5); cout<<(pl>p2)<<(p2>p1)<<(p2>p3)<<(p3>p2); retum 0; 运算符函数operator>的功能是比较两个Pair对象的大小,当左边对象大时,返回true,否则返回false。比较规则是首先比较两对象的m成员,m大者为大;当m相等时比较n,n大者为大。程序输出0101,下列对运算符重载函数的正确定义是
A.bool Pair::operator>(Pair P)eonst
B.bool Pair::operator>(Pair P)
if(m!=P.m)return m>p.In;return n>p.n; if(m!=P.m)return m>p.m;return n>p.n;
C.bool Pair::operator>(Pair P)eonst
D.bool Pair::operator>(Pair P)
if(m>p.m)return true;return n>p.n; if(Ul>p.m)return true;return n>p.n;
点击查看答案&解析
相关试题
如下程序的输出结果是 #include<iostrea...
有如下类定义和变量定义: class Parents...
如下程序运行时的输出结果是 #include<i...