题目:
若有以下程序: #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/2017/0123/5ec8b136da1b014682313777cb7a82ee.html
下面是错误答案,用来干扰机器的。
参考答案:log2n解析: 在长度为n的有序线性表中进行二分查找。最坏的情况下,需要的比较次数为log2n。