单项选择题
设有如下程序:
#include <iostream>
using namespace std;
class A
public:
int i;
display()
cout<<"class A\n";
;
class B
public:
int i;
display()
cout<<"class B\n";
;
class C : public A, public B
int j;
public:
int i;
show ( )
j = i * i;
display();
;
int main()
C demo;
demo.show();
return O;
则主程序运行时将( )。
A.因为变量i的重复定义而报错
B.因为对象demo间接调用display()函数时产生二义性而报错
C.因为类定义的语法错误而不能运行
D.没有语法错误,能够正常输出结果
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
为使下列程序的正确输出结果为: 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);
点击查看答案&解析
单项选择题
下列数组的定义中,会产生错误的是( )。
A.int a[]='0','1','2','3','4','5','6';
B.int a[10]=0,1,2,3,4,5,6;
C.char a[5]="hello";
D.char a[5]='h','e','1','1','o';
点击查看答案&解析
相关试题
有以下程序: #include <iostream> u...
有以下程序: #include <iostream> u...
以下程序的输出结果是 ( )。 #includ...
有如下程序: #include <iostream.h>...
以下程序的功能是:按顺序读入10名学生4...