首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
为使下列程序的正确输出结果为: 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
38
问题
为使下列程序的正确输出结果为: 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全国计算机二级
相关试题推荐
有以下程序#includemain(){inta=1,b=2,c=3,d=0;if(a==1&&b++==2)if(b!=2||c--!=3)printf("%d,%d,%d\n",a,b,c);elseprintf("%d,
有以下程序:#include<stdio.h>main(){inti=0,a=0;while(i<20){for(;;){if((i%5)==0)break;elsei-
若有以下程序structstu{char*name,gender;intscore;};main(){structstua={NULL,’m’,290},b;a.name=(char*)malloc(10);strcpy(a.name,"Z
若要求定义具有10个int型元素的一维数组a,则以下定义语句中错误的是
有以下程序#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语句返回一个函数值,下列选项中错误的程序是()。
C源程序中不能表示的数制是
有以下程序#includemain(){inta=7;while(a--);printf("%d\n",a);}程序运行后的输出结果是
下列描述中,不符合良好程序设计风格要求的是
有以下程序#includeintd=1;voidfun(intp){intd=5;d+=p++;printf("%d",d);}main(){inta=3;fun(a);d+=a++;printf("%d\n",d);}程序
随机试题
类风湿关节炎,正确的摄影体位是
A.左肝下后间隙B.左肝上间隙C.右肝下间隙D.左肝下前间隙E.右肝上间隙网膜囊位置在
关于行业生命周期分析说法正确的是( )。
根据个人所得税的有关规定,下列表述不正确的是()。
习俗水平是指儿童开始关心社会的期望与别人的需要,分为()、遵守法规和秩序定向阶段。
广义上的教育包括_______、_______和_______。
A、 B、 C、 D、 B
Writeanessayof160—200wordsbasedonthefollowingdrawing.Inyouressay,youshould1)describethedrawingbriefly,
turtle库的绘制状态函数是
Therecanbenodoubtthatthegrowthinadvertisementisoneofthemoststrikingfeaturesofthewesternworldinthiscentury
最新回复
(
0
)