首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
为使下列程序的正确输出结果为: Now is 2004-7-6 12:12:12 那么应该在程序划线处填入的语句是( )。 #include <iostream> using namespace std;
为使下列程序的正确输出结果为: Now is 2004-7-6 12:12:12 那么应该在程序划线处填入的语句是( )。 #include <iostream> using namespace std;
admin
2010-03-29
43
问题
为使下列程序的正确输出结果为: Now is 2004-7-6 12:12:12 那么应该在程序划线处填入的语句是( )。 #include <iostream> using namespace std; class TIME; class DATE { public: DATE(int y=2004,int m=1,int d=1) { year=y; month=m; day=d; } void DateTime(TIME &t); private: int year,month, day; }; class TIME { public: TIME(int h=0,int m=0,int s=0) { hour=h; minute=m; second=s; } ______________; //将类 DATE 中成员函数 DateTime 声明为类 TIME 的友元函数 private: int hour,minute, second; }; void DATE: :DateTime(TIME &t) { cout<<"Now is "<<year<<’-’<<month<<’-’<<day<< ’ ’<<t.hour<<":"<<t.minute<<’: ’<<t.seoond<<’.’<<end1; } int main ( ) { DATE d(2004,7,6); TIME t (12, 12, 12); d. DateTime (t); return 0; }
选项
A、friend void DateTime(TIME &t);
B、friend void DATE::DateTime(TIME &0;
C、void DateTime(TIME &t);
D、friend void DateTime(TIME &t);
答案
2
解析
根据要求可知,在横线处是将类DATE中成员函数DateTime声明为类 TIME的友元函数。由于函数DateTime是类DATE的成员函数,因此对DateTime函数的使用要加上“DATE::”修饰。其他各声明的组成部分可参照函数DateTime在类体外的定义实现。
转载请注明原文地址:https://kaotiyun.com/show/lTjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在结构化程序设计中,模块划分的原则是
有以下程序:#include<stdio.h>main(){inti=0,a=0;while(i<20){for(;;){if((i%5)==0)break;elsei-
有以下程序#include<stdio.h>voidmain(){charb,c;inti;b=’a’;c=’A’;for(i=0;i<6;i++){if(i%2)putchar(i+b);elseputchar(i+
若各选项中所用变量已正确定义,函数fun中通过return语句返回一个函数值,下列选项中错误的程序是()。
下列描述中,不符合良好程序设计风格要求的是
有以下程序#includeintd=1;voidfun(intp){intd=5;d+=p++;printf("%d",d);}main(){inta=3;fun(a);d+=a++;printf("%d\n",d);}程序
随机试题
与个眭心理学相类似的性格分析还有
不属于咀嚼肌的是()
¥9700.95的汉字大写金额应写为人民币玖仟柒佰元玖角伍分。()
保本比例是到期时投资者可获得的本金保障比率,常见的保本比例介于()之间。
求微分方程x2y′+xy=y2满足初始条件y(1)=1的特解.
IllegalCookingOilIsEverywhere地沟油无处不在Writeanessayof160-200wordsbasedonthedrawing.Inyouressay,youshould1)desc
SomehistorianssaythatthemostimportantcontributionofDwightEisenhower’spresidency(总统任期)inthe1950swastheU.S.int
如果在SQL查询的SELECT短语中使用TOP,则应该配合使用
ConversationattheairportDeparturetimefortheplane______.______1FlightNo.____
Thenightisnotwhatitwas.Once,theEarthwascastperpetually(永恒地)halfinshadow.Manandbeastsleptbeneathinkyskies,
最新回复
(
0
)