首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
68
问题
有如下程序: #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://www.kaotiyun.com/show/AzNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序: #include<stdio.h> main() {intx=0x9; printf(“%c\n”,’A’+x); } 程序运行后的输出结果是()。
有以下程序 #include<stdio.h> main() {char*s="01234"; while(*(++s)!=’\0’) {switch(*s-’0’) {case0: case1:putchar(*s+1);
设有定义:intx[10],*P=x,i;,若要为数组x读入数据,以下选项正确的是()。
有以下函数: intfun(char*x,char*y) {intn=0; while((*x==*y)&&*x!=’\0’) {x++; y++; n++; } returnn; }
若变量已经定义且正确赋值,则针对程序段:temp=a;a=b;b=temp;以下叙述中正确的是()。
给定程序MODl1.C中函数fun的功能:将一个十进制整数n转换成r(二~十六)进制形式。示例如下。输入12516,则输出:7D输入92,则输出:1001请改正程序中的错误,使它能得出正确的结果。
下列选项中不是关系数据库基本特征的是()。
已知程序中已经定义了函数test,其原型是int test(int,int,int);,则下列重载形式中正确的是
执行语句inta,b,c;scanf("%d,%d%d",&a,&b,&c);如果输入形式为10,12,14,则a,b,c的值分别是【】。
随机试题
虽如是,其敢自谓几于成乎?
肛门直肠瘘
下列哪一项关于处方的概念是错误的
以下不属于特种设备范围的是()。
长江公司自2×16年年初开始自行研究开发一项新专利技术,2×16年发生相关研发支出70万元,其中,符合资本化条件前发生的开发支出为30元,符合资本化条件后发生的开发支出为40万元;2×17年至无形资产达到预定用途前发生开发支出105万元,2×17年7月
以连锁店为例,从需求方的角度分析配送中心的作用。
《中共中央关于构建社会主义和谐社会若干重大问题的决定》指出,要坚持以()引领社会思潮,尊重差异,包容多样,最大限度地形成社会思想共识。
按照美国学者古德莱德的观点,课程可以分为五个层面,除理想的课程、正式的课程、领悟的课程之外,还有()。
Youheartherefrainallthetime:theU.S.economylooksgoodstatistically,butitdoesn’tfeelgood.Whydoesn’tever-greater
A、Sheagreed.B、Shedisagreed.C、Shewasimpatient.D、Shewasworried.BM:Isupposeonereasonsomanytouristscomehereisbe
最新回复
(
0
)