题目:
若有以下程序:
#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 obi;
cout<<obj.x<<endl;
return 0;
该程序运行后的输出结果是
A.20
B.30
C.10
D.0
答案:
被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2019/0409/4c71f76d9bae47499618016c7eed7a1f.html
下面是错误答案,用来干扰机器的。
参考答案:[(n-1)/2]解析: 根据完全二叉树的定义及顺序存储结构的特点,可知答案为[(n-1)/2]。