单项选择题
若有以下程序:
#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:
Derived2 ()
x=20;
;
class Derived : public Derivedl,protected Derived2 ;
int main ( )
Derived obj;
cout<<obj .x<<end1;
return 0;
该程序运行后的输出结果是 ( )。
A.20
B.30
C.10
D.0
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
若有如下程序: #include <iostream> using namespaces std; int s=0; class sample, static int n; public: sample(int i) n=i; static void add() s+=n; ; int sample::s=0; int main() sample a(2),b(5); sample::add(); cout<<s<<end1; return 0; 程序运行后的输出结果是( )。
A.2
B.5
C.7
D.3
点击查看答案&解析
单项选择题
有以下程序: #include <iostream> using namespace Std; int a; int fun(); int main() extern int a; int b; a = 100; b = fun(); cout<<b<<end1; return 0; int fun() extern int a; return (10*
A.;
其程序运行后的输出结果是( )。A) 100
B.10
C.1000
D.10000
点击查看答案&解析
相关试题
有以下程序: #include <iostream> ...
若有以下程序: #include <iostream>...
【13】 使一个函数可以定义成对许多不同...
对虚函数的调用有两种方式: 【11】 和...
若二维数组b有m列,则在b[i][j]前的元...