有如下程序:#includeiostreamusingnamespacestd;classPair{intm,n;public;Pair(intj,intk):m(j),n(k){}intget(){returnm;}intget()const{returnm+n;}};intmain(){Paira(3,5);constPairb(3,5);couta.get()b.get();return0;}运行时的输出结果是( )。A.33B.38C.83D.88

有如下程序:

#include<iostream>

usingnamespacestd;

classPair{

intm,n;

public;

Pair(intj,intk):m(j),n(k){}

intget(){returnm;}

intget()const{returnm+n;}

};

intmain(){

Paira(3,5);

constPairb(3,5);

cout<<a.get()<<b.get();

return0;

}

运行时的输出结果是( )。

A.33

B.38

C.83

D.88


相关考题:

有如下程序:includeusing namespace std;class Base{int x;public:Base(int n=0):x(n 有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int getX( )const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m),Base(n){tout<<m;} Derived(int m):y(m){cout<<m;} }; int main( ){ Derived dl(3),d2(5,7); return 0; } 程序的输出结果是A.375B.357C.0375D.0357

有如下程序:includeusing namespace std;class Base{protected:int i;public:int j;} 有如下程序: #include<iostream> using namespace std; class Base{ protected:int i; public:int j; }; class Derived:public Base{ int m; public:int n; }; int main( ){ Derived d; d.i=0; //[1] d.j=0; //[2] d.n1=0; //[3] d.n=0; //[4] return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是A.[1]和[2]B.[1]和[3]C.[2]和[3]D.[2]和[4]

有如下程序: include using namespace std; class Pair{ int m, n; public: Pair(int 有如下程序:#include<iostream>using namespace std;class Pair{int m, n;public:Pair(int j, int k):m(j), n(k){}int get(){return m;}int get()const{return m+n;)};int main() {Pair a(3, 5);const Pair b(3, 5);cout<<a. get()<<b. get();return 0;}运行时的输出结果是( )。A) 33B) 38C) 83D) 88A.B.C.D.

有如下程序: include using namespace std; class Base{ public: int m,n; }; class D 有如下程序:include<iostream>using namespace std;class Base{public:int m,n;};class Derived1:【 】Base{};class Derived2:public Derived1{public:void SetMN(int M,int N){m=M;n=N;}int GetSumMN(){return(m+n);}};int main() {Derived2 objD;ohjD. SetMN(3,4);cout<<"M+N="<<objD, m+objD, n<<endl;return 0}编译时只有“cout<<"M+N"<<objD.m+objD.n<<endl;”有语法错误,程序的其他地方没有语法错误。请判断下划线处使用的关键字是什么。

有如下程序: #includeiostream usingnamespacestd; classPair{ intm,n; public; Pair(intj,intk):m(j),n(k){} intget( ){returnIn;} intget( )const{returnm+n;} }; intmain( ){ Paira(3,5); constPairb(3,5); couta.get( )tb.get( ); return0; } 运行时的输出结果是( )。A.33B.38C.83D.88

有如下程序: #includeiostream using namespace std; class Pair{ int m,n; public: Pair(int j,int k):m(j),n(k){} int get{return m;} int getconst{return m+n;} }; int main{ Pair a(3,5); const Pair b(3,5); touta.get’b.get; return U: } 执行这个程序的输出结果是( )。A.33B.38C.83D.88

有下列程序: include using namespace std; classBase { protected: int i; public 有下列程序: #include<iostream.h> using namespace std; classBase { protected: int i; public: int j; }; classDerived:public Base { int m; public: intn; }; intA.[1]和[2]B.[1)和[3]C.[2]和[3]D.[2]和[4]

有如下程序:includeusing namespaee std;class Pair{int m;int n;public:Pair(int i, 有如下程序: #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)eonstB.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)eonstD.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 using namespace std;classBase{protected:int i:public:int j 有如下程序: #include <iostream.h> using namespace std; class Base { protected: int i: public: int j; }; class Derived: public Base { int m: public: int n; } int main() { Derived d: d.i=0; //[1] d.J=0; //[2] d.m=0; //[3] d.n=0: //[4] return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是A.[1]和[2]B.[1]和[3]C.[2]和[3]D.[2]和[4]