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

admin2013-05-30  34

问题 若有以下程序:
#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;
}
该程序运行后的输出结果是【  】。

选项

答案20

解析
转载请注明原文地址:https://jikaoti.com/ti/BNE0FFFM
0

最新回复(0)