[单选题]

有如下程序: #include<iostream) using namespace std; classBase{ public: Base(int x=0){cout<<x;} }; Class Derived:public Base{ public: Derived(int x=0){cout<<x;} private: Base Val; }; int main(){ Derived d(1); return

A.100

B.000

C.010

D.001

参考答案与解析:

相关试题

有如下程序:#include<iostream)using namespace

[单选题]有如下程序: #include<iostream) using namespace std; int main() { int*p; *p=9; cout<<“The value at p:”<<*p; return 0; } 编译运行程序将出现的情况是( )。A.编译时出现语法错误,不能生成可执行文件B.运行时一定输出:The value at p:9C.运行时一定输出:The value at p:*9D.运行时有可能出错

  • 查看答案
  • 有如下程序:#include<iostream)using namespace

    [单选题]有如下程序: #include<iostream) using namespace std; classBASE{ public: ~BASE(){cout<<“BASE”;} }; class DERIVED:public BASE{ public: ~DERIVED(){COUt<<“DERIVED”;} }; int main(){DERIVED x;return 0;} 执行后的输出结果是( )。A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE

  • 查看答案
  • 有如下程序:#include<iostream)using namespace

    [单选题]有如下程序: #include<iostream) using namespace std; class AA{ int n; public: AA(int k):n(k){} int get(){return n;} int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); COUt<<A.get()<<b.get(); return 0A.55B.57C.75D.77

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class AA{public:A.A(){tout<<‘l’;}};class BB:public AA{int k;public:B.B():k(0){cout<<…2;}B.B(int n):k(n){cout<<‘3’;}};int main(){B.B b(4),C;return 0;}A.1312B.132C.32 D、1412

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class Publication{//出版物类char name[30];public:Publication(char*name=”未知名称”){strcpy(this->name,name);}const char*getName()const{return name;}virtual const char*getType()const{return“未知类型”;}};class Bo

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class A{public:A.(int i):r1(i){}void print(){cout<<‘E’<<rl<<‘-’;}void print()const{cout<<‘C’<<rl*rl<<‘-’;}private:int rl:};int main(){A. a1(2); const A a2(4);a1.pri

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class C1{public:-Cl()}cout<<1;}};class C2:public C1{public:~c2(){cout<<2;}};int main(){C.2 cb2;C.1*cbl:return 0;{运行时的输出结果是A.121B.21C.211 D、12

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class Toy{public:Toy(char*_n){strcpy(name,_n);count++;}~Toy()}count--;}char*GetName(){return name;}static int getCount(){return count;}private:char name[10];static int count;};int Toy::count=O:int mai

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class Book{public:B.ook(char*t=””){strcpy(title,t);}private:char title[40];};class Novel:public Book{public:Novel(char *t=””):Book(t){}char*Category()const{return”文学”;)};int main(){B.ook *pb;pb=new No

  • 查看答案
  • 有如下程序:#include<iostream>using namespace

    [单选题]有如下程序:#include<iostream>using namespace std;class Instrument{public:virtual void Display()=0;};class Piano:public Instrument {public:void Display(){/*函数体程序略*/}};int main(){Instrument s;Instrument *p=0;//…;return 0;}下列叙述中正确的是A.语句“Instrument *p=0

  • 查看答案
  • 有如下程序:#include<iostream)using namespace