题目内容 (请给出正确答案)
[主观题]

有如下程序:}}}}include<iostream>using namespace std;class Pair{int m;int n;public:Pa

有如下程序:

}}}}include<iostream>

using namespace std;

class Pair{

int m;

int n;

public:

Pair(int i,int J):m(i),n(J){}

bool 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);

return 0;

{

运算符函数operator>功能是比较两个Pair对象的大小,当左边对象大时,返回true,否则返回false。比较规则是首先比较两对象的m成员,m大者为大;当m相等时比较n.n大者为大。程序输出0101,下列对运算符重载函数的正确定义是

A.bool Pair::operator>(Pair P)const {if(m!=P.m)return m>P.m;return n>P.n;)

B.bool Pair::operator>(Pair P) {if(m!=P.m)return m>P.m;return n>P.n;)

C.bool Pair::operator>(Pair P)const {if(m>P.m)return true;return 11>P.n;)

D.bool Pair::operator>(Pair P) {if(m>P.m)return true;return 11>P.n;}

提问人:网友stlzlg 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有如下程序:}}}}include<iostream>usi…”相关的问题
第1题
有如下程序: #include #include usingnamespacestd; intmain()(cout$amp;A.***123***456

B.***123456***

C.***123456

D.123456

点击查看答案
第2题
有如下程序 #include <stdio.h>

B、98765

C、'9''8''7''6''5'

D、'43210'

点击查看答案
第3题
有如下程序 #include <stdio.h>

A.ABC

B.012

C.abc

D.123

点击查看答案
第4题
现有如下程序段,此程序段编译有错误,则程序段的错误出在include<stdio.h>main()这个语句
点击查看答案
第5题
有如下程序 #include <stdio.h>

A.MN

B.LK

C.OP

D.MM

点击查看答案
第6题
现有如下程序段,此程序段编译有错误,则程序段的错误出在 include main()这个语句
点击查看答案
第7题
有如下程序: #include<iostream> using namespace std; int main() { cout.f

有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是

A.###123

B.123###

C.***123

D.123***

点击查看答案
第8题
有如下程序: #include <iostream> #include <iomanip> using namespace std; int main() {cout.f

有如下程序: #include <iostream> #include <iomanip> using namespace std; int main() { cout.fill('*'); cout.width(6); cout.fill('#'); cout<<123<<end1; return 0; } 执行生的输出结果是()。

A. ###123

B.123###

C. ***123

D.123***

点击查看答案
第9题
有如下程序: #include<iomanip> #include<iostream> using namespace std; int main(){ cout<<se

有如下程序:

#include<iomanip>

#include<iostream>

using namespace std;

int main(){

cout<<setfill('*')<<setw(6)<<123<<456;

return 0;

}

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

A) ***123***456

B) ***123456***

C) ***123456

D) 123456

点击查看答案
第10题
有如下程序:#include <iostream>using namespace std;class AA{public: virtual void f() {cout<

有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla

A.AA

B.AABBCC

C.BBAABBCC

D.BBBBAACC

点击查看答案
第11题
有如下程序 #include<iostream> #include<iomanip> using namespace std; int main(

有如下程序 #include<iostream> #include<iomanip> using namespace std; int main(){ cout<<setprecision(3)<<fixed<<setfill('*')<<setw(8); cout<<12.345<<_______<<34.567; return 0; } 若程序的输出是: ** 12.345**34.567 则程序中下划线处遗漏的操作符是

A.setprecision(3)

B.fixed

C.setfill('*')

D.setw(8)

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信