[单选题]

若有以下程序: include using namespace std;class Base{public:Base ( ){x=0;}int x

若有以下程序:# include <iostream>using namespace std;class Base{public: Base ( ) { x=0; } int x;};class Derived1 : virtual public Base{public: Derived1 ( ) { x=10; }}; class Derived2 : virtual public Base{public: Derived2 () { x=20; }};class Derived : public Derived1,protected Derived2{ };int main(){ Derived obj; cout<<obj.x<<end1; return 0;} 该程序运行后的输出结果是

A.10

B.20

C.30

D.0

参考答案与解析:

相关试题

有以下程序: include using namespace std; cla

[主观题]有以下程序: include using namespace std; class sample {int x; public:void setx(有以下程序:include <iostream>using namespace std;class sample{int x;public:void setx(int i){x=i;}int putx (){return x;}};int main ( ){sample *p;sample A[3];A.[0] .set>:(5);A.[1] .s

  • 查看答案
  • 若有以下程序:#include using namespaces std;cla

    [单选题]若有以下程序:include using namespaces std;class A{public: A (){} A (int i) {x1=若有以下程序: #include <iostream> using namespaces std; class A { public: A (){} A (int i) { x1=i; } void dispa() { cout<<"xl="<<xl<<" , "; } private: int x1; }; class B : public

  • 查看答案
  • 若有以下程序:#include using namespaces std;cla

    [单选题]若有以下程序:include using namespaces std;class A {public: A(){} A(int i) {x1=i若有以下程序: #include <iostream> using namespaces std; class A { public: A(){} A(int i) { x1=i; } void dispa() { cout<<'x1="<<x1<<","; } private: int x1; }; class B: public A { p

  • 查看答案
  • 若有以下程序: include using namespace std; cl

    [主观题]若有以下程序: include using namespace std; class sample { int x; public: sample若有以下程序:include <iostream>using namespace std;class sample{int x;public:sample(){}void setx(int i){x=i;}friend iht fun(sample B[],int n){int m=0;for{int i=0;i<n;i++)if(B[i].x>m)

  • 查看答案
  • 若有以下程序:#include using namespace std;int

    [单选题]若有以下程序:include using namespace std;int f(){static int i = 0;int s = 1;s£«=若有以下程序: #include <iostream> using namespace std; int f() { static int i = 0; int s = 1; s+=i; i++; return s; } int main() { int i,a = 0; for(i = 0;i<5;i++) a+=f(); cout<<a<<end

  • 查看答案
  • 若有以下程序#include using namespace std;class

    [单选题]若有以下程序include using namespace std;class A{public: A(int i,int j) {a=i;b=j若有以下程序 #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x, int y) { a+=x; b+=y; } void show() { cout < <a < <" , " <<b<< e

  • 查看答案
  • 若有以下程序:#include using namespace std;clas

    [单选题]若有以下程序:include using namespace std;class Base {public:Base() { x=0; } int若有以下程序: #include <iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl: virtual public Base { public: Derivedl() { x=10; } }; class Deriv

  • 查看答案
  • 若有以下程序:#include using namespace std;#def

    [单选题]若有以下程序:include using namespace std;define PI 3.14class Point{private: in若有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { re

  • 查看答案
  • 若有以下程序:#include using namespace std;clas

    [单选题]若有以下程序:include using namespace std;class A{private: int a;public: A(int i若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<", "; } }; class B { private: int b; public: B(int

  • 查看答案
  • 若有以下程序:#include using namespace std;clas

    [单选题]若有以下程序:include using namespace std;class Base{public:Base (){x=0;}int x;}若有以下程序: #include <iostream> using namespace std; class Base { public: Base () { x=0; } int x; }; class Derived1 : virtual public Base { public: Derived1 () { x=10; } }; class De

  • 查看答案
  • 若有以下程序:# include using namespace std;cla