首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespaee std; class Pair{ int m; int n; public: Pair(int i,int j):m(i),n(j
有如下程序: #include<iostream> using namespaee std; class Pair{ int m; int n; public: Pair(int i,int j):m(i),n(j
admin
2013-02-27
47
问题
有如下程序: #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;}
答案
C
解析
转载请注明原文地址:https://kaotiyun.com/show/AzNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
使用数组名作为函数的实参时,传递给形参的是()。
有以下程序: #include<stdio.h> voidf(int*p,int*q); main() { intm=1,n=2,*r=&m; f(r,&n); printf("%d,%d",m,n); } voi
有如下程序 #include<stdio.h> structnode { charid; structnode*next; }a={’A’},b={’B’},c={’C’},*p=&a,*pt; main() {
有3个关系R、S和T如下所示: 则由关系R和关系s得到关系T的运算是()。
若变量x、y已正确定义并赋值,以下符合C语言语法的表达式是()。
若有定义:doublea=22;inti=0,k=18;,则不符合C语言规定的赋值语句是()。
以下都是C++语言标识符的是()。
若有定义:intk,*q;,则下列各选项中赋值表达式正确的是()。
随机试题
将病人随机分成试验组和对照组,分别给予药物和安慰剂或参照处理,然后评价药物效果的流行病学的研究方法是
IAaskedhimBwherehe’dlikeCtoDgoto.
时间速度积分的单位是
如果使用审计抽样实施控制测试没有为得出有关测试总体的结论提供合理的基础,下列有关注册会计师采取的措施中,错误的是()。
阅读下面材料,回答问题。“苦难是人生的一笔财富。”这是人们常说的一句激励、奋进的话,但学会正确对待苦难更有现实的意义,毕竟,苦难不是幸事,也不是每个人都能承受得起的。在一次聚会上,那些堪称成功的实业家、明星谈笑风生,其中就有著名的汽车商约
计算机辅助教学中的教学模式是()的有机结合,是为完成现代教学与学习任务采用的相对稳定的,用以设计、组织、实施、评估、优化教学与学校的策略方法和结构的简化形式。
1/2
Writeanessaybasedonthefollowingchart.Youshoulddescribethechartandgiveyourcomments.Youshouldwriteabout15
•Readthearticlebelowabouteducationalbackgroundofsuccessfulmanagers.•Choosethebestwordtofilleachgap,fromA,B
Asmytrainwasnotduetoleaveforanotherhour,Ihadplentyoftimetospare.Afterbuyingsome【B1】______toreadonthejou
最新回复
(
0
)