有如下程序: #inCludeiostream using namespaCe std; ClaSS A{ publiC: A(int i){x=i;} void dispa( ){Coutx’,’;} private: int x; }; Class B:publiC A{ publiC: B(int i):A(i+10){x=i;} vold dispb( ){dispa( );Coutxendl;} private: int x; }; int main( )} B b(2); b.dispb( ); return 0; } 执行这个程序的输出结果是( )。A.10,2B.12,10C.12,2D.2,2

有如下程序: #inClude<iostream> using namespaCe std; ClaSS A{ publiC: A(int i){x=i;} void dispa( ){Cout<<x<<’,’;} private: int x; }; Class B:publiC A{ publiC: B(int i):A(i+10){x=i;} vold dispb( ){dispa( );Cout<<x<<endl;} private: int x; }; int main( )} B b(2); b.dispb( ); return 0; } 执行这个程序的输出结果是( )。

A.10,2

B.12,10

C.12,2

D.2,2


相关考题:

下面程序运行后输出的结果是【】。 include using namespace std; class example{ const 下面程序运行后输出的结果是【 】。include <iostream>using namespace std;class example{const int m;public:example(int i):m(i){}void pr(){cout<<"m="<<m<<endl'}};int main(){example x(100);x.pr();return 0;}

有以下程序: include using namespace std; class sample {int x; public:void setx( 有以下程序:include <iostream>using namespace std;class sample{int x;public:void setx(int i){x=i;}int putx (){return x;}};int main ( ){sample *p;sample A[3];A[0] .set>:(5);A[1] .setx(6);A[2] .setx(7);for (int j=0;j<3;j++){p=A[j];cout<<p->putx () <<", ";}cout<<end1;return 0;}执行后的输出结果是【 】。

若有以下程序: include using namespace std; class sample { int x; public: sample 若有以下程序:include <iostream>using namespace std;class sample{int x;public:sample(){}void setx(int i){x=i;}friend iht fun(sample B[],int n){int m=0;for{int i=0;i<n;i++)if(B[i].x>m)m=B[i].x;return.m;}};int main ( ){sample A[10];int arr[]={90,87,42,78,97,84,60,55,78,65};for(int i=O;i<10;i++)A[i].setx(arr[i]);cout<<fun(A, 10)<<end1;return 0;}该程序运行后的输出结果是【 】。

有如下程序: include using namespace std; class Base { public: 有如下程序: #include <iostream> using namespace std; class Base { 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 0; }程序的输出结果是A.0B.1C.1D.1

有如下程序:includeusing namespace std;Class TestClass{private:int x,y;public:Te 有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void print()const { cout<<”prinA.printlB.print2C.printl print2D.程序编译时出错。

有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a=i 有以下程序: #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<<“,”;A.10,10,10B.10,12,14C.8,10,12D.8,12,10

若有如下程序:includeusing namespace std;Class TestClass1{private:int a;public:T 若有如下程序: #include<iostream> using namespace std; Class TestClass1 { private: int a; public: TestClassl(int i) { a=i; } void disp() { cout<<a<<“,”; } }; Class TestClass2 { private: int b; publicA.10,10,10B.10,12,14C.8,10,12D.8,12,10

有如下程序:include using namespace std;class sample{private:int x,y;public: sam 有如下程序: #include <iostream> using namespace std; class sample { private: int x,y; public: sample(int i,int j) { x=i; y=j; } void disp () { cout<<"disp1"<<end1; } void disp() const { cout<<"disp2"<<end1; };int main () { const sample a(1,2); a.disp(); return 0; } 该程序运行后的输出结果是A.disp1B.disp2C.disp1 disp2D.程序编译时出错

有以下程序:include using namespace std; class Base { public: Base() { K=0; } int 有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base

有以下程序 include using namespace std; class Base { int a; public: Base(int x) 有以下程序include <iostream>using namespace std;class Base{int a;public:Base(int x){ a=x; }void show(){ cout<<a; }class Derived : public Base{int b;public:Derived(int i) :Base(i+1),b(i){}void show() { cout<<b;};int main (){Base b(5),*pb;Derived d(1);pb=d;pb->show ();return 0;}运行后的打印结果是______。

有如下程序;include using namespace std;class Base{public;Base(inti){x=i;}void d 有如下程序; #include <iostream> using namespace std; class Base { public; Base(inti){x=i;} void dispa0{cout<<x<<',';} private; int x; }; class Derived;public Base { public; Derived(int i);Base(i+10) {x=i;) void dispb(){dispa();cout<<x<<end1;} private; int x; }; int main() { Derived b(2) ; b.dispb(); return 0; } 运行的结果是( )。A.2,2B.12,2C.12,10D.10,2

有以下程序:include using namespace std;class A{public: A(int i,int j) { a=i; b= 有以下程序: #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { cout<<a<<","<<b<<end1; } private: int a,b; }; class B: private A { public: B(int i,int j): A(i,j) {} void fun() { move(3,5); } void fl () { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3

下面程序的打印结果是【】。 include using namespace std; class Base { public:Base(i 下面程序的打印结果是【 】。include <iostream>using namespace std;class Base{public:Base(int x){a=x;}void show(){cout<<a;}private:int a;};class Derived : public Base{public:Derived(int i) :Base(i+1) ,b(i) { }void show(){cout<<b;}private:int b;};int main ( ){Base b(5) , *pb;Derived d(1);pb=d;pb->show();return 0;}

有如下程序:include using namespace std;class sample{private: int x, y;public: s 有如下程序: #include <iostream> using namespace std; class sample { private: int x, y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"displ"<<end1; } void disp() const { cout<<"disp2"<<end1; } }; int main () { const sample a(i,2); a.disp (); return 0; } 该程序运行后的输出结果是( )。A.disp1B.disp2C.disp1 disp2D.程序编译时出错

有以下程序:include using namespace std;int s=0;class sample{ static int n;publi 有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;A.2B.5C.7D.3

有如下程序:include using namespace std;Class x{protected: int a;public: x() {a= 有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<A.1B.123C.242D.244

有如下程序:include using namespace std;int s=0;class sample { static int n;publ 有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };A.2B.5C.7D.3

设有如下程序: include using namespace std; class A { public:int i;display(){co 设有如下程序: #include <iostream> using namespace std; class A { public: int i; display() { cout<<"class A\n"; } }; class B { public: int i; display() { cout<<"class B\n"; } }; class C : public A, public B { int j; public: int i; show ( ) { j = i * i; display(); } }; int main() { C demo; demo.show(); return O; } 则主程序运行时将( )。A.因为变量i的重复定义而报错B.因为对象demo间接调用display()函数时产生二义性而报错C.因为类定义的语法错误而不能运行D.没有语法错误,能够正常输出结果

有如下程序:includeusing namespace std;Class TestClass{int a;public:TestClass(in 有如下程序: #include<iostream> using namespace std; Class TestClass {int a; public: TestClass(int x){a=x;} void show(){cout<<a;}}; class TestClass1:public TestClass {int b; public: TestClass1(int i):TestClass(i+1),b(i){} voiA.5B.1C.0D.2

若有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a 若有以下程序: #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<<A.10,10,10B.10,12,14C.8,10,12D.8,12,10

有下列程序:includeUsing namespace std;Class Amount{ int amount;public; Amount(i 有下列程序: #include<iostream> Using namespace std; Class Amount{ int amount; public; Amount(int n=O):amount(n){} Int getAmount()const{return amount;} Amount operator+=(AmountA) {A.*thisB.thisC.amountD.amount

有下列程序:includeusing namespace std;class TestClass{private:int x,y;public:Te 有下列程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"printl"<<endl; } voA.print1B.print2C.pfint1 print2D.程序编译时出错

下列程序的输出结果是()。 include using namespace std; class TestClass{ static in 下列程序的输出结果是( )。 #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){retum i;} }; int TestClass∷i=0; voiA.111B.121C.211D.221

有如下程序: include using namespace std; class TestClass { int a 有如下程序: #include<iostream> using namespace std; class TestClass { int a; public: TestClass(int x){a=x;} void show(){cout<<a;} }; class TestClass1:public TestClass { int b; public: TestClass1(int i):TestClass(i+1),b(i){} void show(){cout<<b;} }; int main() { TestClass b(5),*p; TestClass1 d(1); p=d; p->show(); return 0; } 该程序运行后的打印结果是( )。A.5B.1C.0D.2

若有以下程序:include using namespace std;class Base{private: int x;protected: i 若有以下程序: #include <iostream> using namespace std; class Base { private: int x; protected: int y; public: int z; void setx(int i) { x=i; int getx () { return x; } }A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5

若有以下程序:include using namespace std;class A{private: int a;public: A(int 若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:A.10,10,10B.10,12,14C.8,10,12D.8,12,10

在下面横线上填上适当的语句,完成程序。include using namespace std; class Base { in 在下面横线上填上适当的语句,完成程序。include<iostream>using namespace std;class Base{int x;public:Base(int i){x=i;}~Base(){});class Derived:public Base{public:______//完成类Derive构造函数的定义};iht main(){Derived obj