首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义 class MyClass public: _________ Private: int data; }; 若要为MyClass类重载流输入运算符>>,使得程序中可以“cin>>obj;
有如下类定义 class MyClass public: _________ Private: int data; }; 若要为MyClass类重载流输入运算符>>,使得程序中可以“cin>>obj;
admin
2019-04-01
108
问题
有如下类定义
class MyClass
public:
_________
Private:
int data;
};
若要为MyClass类重载流输入运算符>>,使得程序中可以“cin>>obj;”形式输入MyClass类的对象obj,则横线处的声明语句应为( )。
选项
A、friend istream&operator>>(istream&is,MyClass&a);
B、friend istream&operator>>(istream&is,MyClass a);
C、istream&operator>>(istream&is,MyClass&a);
D、istream&operator>>(istream&is,MyClass a);
答案
A
解析
C++的输入运算符>>作为非类成员函数重载。在一个类中,可将输入运算符>>声明为友元函数,在类MyClass重载输入运算符>>的形式如选项A所示。
转载请注明原文地址:https://www.kaotiyun.com/show/AlAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序的运行结果为#include<iostream.h>template<classTT>classFF{TTa1,a2,a3;public:FF(TTb1,TTb2,TTb3){a1=b1;
有以下程序:voidfun(inta*a,inti,inti){intt;if(i<j);{t=a[i];a[i]=a[j];a[j]=t;fun(a,++i,--j);}}main
有以下程序段:intk=0;while(k=1)k++;while循环执行的次数是()。
有如下程序:#include<iostream>usingnamcspacestd;intmain(){voidfunction(doubleval);doubleval;function(v
下列情况中,不会调用复制构造函数的是
数据库技术的根本目标是要解决数据的
下列关于完全二叉树的叙述中,错误的是()。
软件开发离不开系统环境资源的支持,其中必要的测试数据属于
关于二义性的描述错误的是
已知一棵二叉树的先根序列为ABCDEFK,中根序列为DGBAFCK,则结点的后根序列为()
随机试题
某农药厂生产工人,因西维因中毒入院,以毒蕈碱样症状为主,全血胆碱酯酶活性为70%。治疗该种中毒病例不宜应用
设有抵押权的房屋被拆迁时,应按()等程序进行补偿安置。
地陪与领队或全陪核对和商定接待计划的必要性有哪些()
共生营销,是指两个或两个以上的企业通过分享市场营销中的资源,达到降低成本、提高效率、增强市场竞争力为目的的一种营销策略。根据上述定义,下列属于共生营销的是()。
Rao’s,thelegendaryeastHarlemItalianeatery,ismorethanahundredblocksaboveWallStreet.Butwithaclientelethatincl
Leavingtheregion’seconomicwoesbehind,moreyoungAsiansthaneveraregoingtoAmericatogettheirMBAs.Fortuneranksthe
A、Yes,Ilooktired.B、Yeah,I’msure.C、I’vegotaheadache.D、Don’tmentionit.C本题考查的是对疑问句的回答。题目中问的是“为什么你看起来这么累?”A、B、D没有解释原因
A、HewantstoknowthetemperatureinFahrenheit.B、HewantstoknowthetemperatureinCentigrade.C、Thenewscastersalwayscon
Itmusthavebeenaftertwoo’clockinthemorningwhenthelastguests【C1】______theirleave,andalthoughwehadenjoyedthe
Asanopportunitytohighlightwomen’scontributions,InternationalWomen’sDayhasalwaysservedtocommemorate(纪念)thecutting
最新回复
(
0
)