单项选择题
若有以下程序:
#include<iostream>
using namespace std;
class Base
public:
Base()
x=0;
int x;
;
class Derivedl:virtual public Base
publiC:
Derivedl()
X=10;
;
Class Derived2:Virtual public Base
public:
Dedved2()
x=20;
;
class Derived:public Delivedl,protected Derived2;
int main()
Derived obj;
cout<<obj.X<<endl;
return 0;
该程序运行后的输出结果是( )。
A.20
B.30
C.10
D.0
点击查看答案
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #inchde<iostream.h> void fun(int &x,int y)int t=x;x=y;y=t; int main() int a[2]=23,42); fun(a[1],a[0]); std::cout<<a[0]<< , <<a[1]<<Std::endl; return 0; 执行后的输出结果是( )。
A.42,42
B.23,23
C.23,42
D.42,23
点击查看答案
单项选择题
下列类的定义中,有( )处语法错误。 class Base publiC: Base() Base(int i) data=i; ptivate: int data; ; class DeriVe:public Base public: Derive():Base(0) Derive(int x) d=x; void setvalue(int i) data=i; private: d; ;
A.1
B.2
C.3
D.4
点击查看答案
相关试题
执行以下程序后,输出“#”号的个数是 【...
阅读以下程序: #include<iostream.h>...
若有如下程序段: #include<iostream>...
阅读下面的程序: #include<iomanip.h...
以下程序的执行结果是 【12】 。 #in...