单项选择题

有如下程序: #include <iostream.h> using namespace std; class Base { public: Base(){ cout<<"BB"; f(); } voidf(){cout <<"Bf"; } }; class Derived: public Base { public: Derived (){cout<<"DD";} void f(){cout<<"Df";} }; int main(){Derived d; return 0;} 执行上面的程序将输出

A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
<上一题 目录 下一题>
热门 试题

单项选择题
有以下程序: #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 j) { b=j; } void disp() { cout<<b<< , ; } }; class C : public B,public A { private: int c; public: C(int k) :A(k-2),B(k+2) { c=k; } void disp () { A::disp (); B::disp (); cout<<c<<endl; } }; int main () { C obi (10); obj.disp (); return 0; } 程序执行后的输出结果是
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
单项选择题
下列类的定义中,有( )处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive() : Base(0) {} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: d; };
A.1
B.2
C.3
D.4
相关试题
  • 下面是一个栈类的模板,其中push函数将元素...
  • 非成员函数应声明为类的______函数才...
  • 多数运算符既能作为类的成员函数重载,也能...
  • 在下面程序的横线处填上适当的语句,使该程...
  • 下列程序将x、y和z按从小到大的顺序排列,...