有如下程序: 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 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.5
B.1
C.0
D.2
相关考题:
有如下程序: include using namespace std; class TestClass{ int k; public: TestCla 有如下程序:include<iostream>using namespace std;class TestClass{int k;public:TestClass(int x=1):k(x){}~TestClass O{cout<<k;}};int main(){TestClass a[]={TestClass(3),TestClass(3),TestClass(3)};TestClass *p=new TestClass[2];delete []p;return ():}这个程序的输出结果是______。
有如下程序: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 TestClass{public:void who(){cout 若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<“TestClass”<<endl;} }; class TestClassl:public TestClass { public: void who(){cout<<“TestClassl”<<endl; int main() { TestCA.TestClasslB.TestClassC.0D.无输出
若有如下程序: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 TestClass1 { public: TestClass1(){ 有下列程序:include<iostream>using namespace std;class TestClass1{public:TestClass1(){cout<<"A";}};class TestClass2<public:TestClass2(){cout<<"B";}};class TestClass3:public TestClass1{TestClass2 b;
有如下程序: include using namespace std; class BASE { public 有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有如下程序:includeusing namespace std;class TestClass{static int i;public:TestC 有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=0; void f(){TestClass obj2;cout<<obj2.getVal();} int main(){ TestClass obj 1; f(); TestClass *obj3=new TestClass;cout<<obj3->getVal(); delete obj3;cout<<TestClass::getVal(); return 0; } 程序的输出结果是( )。A.232B.221C.222D.231
有如下程序:includeusing namespace std;class TlestClass{int n;public:TestClass(i 有如下程序: #include<iostream> using namespace std; class TlestClass { int n; public: TestClass(int k):n(k){} int get(){return n;} int get()const{return n+1;} }; int main() { TestClass p(5); colast TestClass q(6); cout<<p.get()<<q.get(); return 0; } 执行后的输出结果是( )。A.55B.57C.75D.77
有如下程序:includeusing namespace std;class TestClass{private;char c;public;Tes 有如下程序: #include<iostream> using namespace std; class TestClass { private; char c; public; TestClass (char n):c(n){} ~TestClass () { cout<<c; } }; class TestClass1:public TestClass { Private: char c; public: TestClass1(char n):TestClass (n+1),c(n){} ~TestClass1() { cout<<c; } }; int main() { TestClass1 obj('x'); return 0; } 执行上面的程序输出( )。A.xyB.yxC.xD.y
有如下程序:includeusing namespace std;{TestClass(){cout 有如下程序: #include<iostream> using namespace std; { TestClass(){cout<<"BB";fun()} void fun(){cout<<"Bf";} }; class TestClass1:public TestClass { public: TestClass1(){cout<<"DD";} void fun(){cout<<"Df";} }; int main() {TestClass1 d; return 0;} 执行上面的程序将输出( )。A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
有如下程序: include using namespace std; class PARENT { public: PARENT() { cout 有如下程序:include <iostream>using namespace std;class PARENT{public:PARENT() { cout <<"PARENT"; }};class SON : public PARENT{public:SON() {cout << "SON"; }};int main(){SON son;PARENT *p;p = son;return 0;}执行上面程序的输出是______。
有如下程序:includeincludeusing namespace std;class TestClass{public;T 有如下程序: #include<iostream> #include<iomanip> using namespace std; class TestClass{ public; TestClass (){cout<<'A';} TestClass(char C){cout<<c;) ~TestClass (){cout<<'B';} }; int main(){ TestClass p1,*p2; p2=new TestClass('X'); delete p2; return 0; } 执行这个程序的结果是( )。A.ABXB.ABXBC.AXBBD.AXB
有如下的程序: include using namespace std; class AT{friend ostream operato 有如下的程序:include<iostream>using namespace std;class AT{friend ostream operator<<(ostream,AT);}at;ostream operator<<(ostream os,AT){return os<<'@';}int main(){cout<<"MyHome"<<at<<"isHere.com";}执行上面的程序将输出
有如下程序: include using namespace std; class TestClass { private: int x,y; pu 有如下程序: #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"<<end1; } void print()const { cout<<"print2"<<end1; } }; int main() { const TestClass a(1,2); a.print(); return 0; } 该程序运行后的输出结果是( )。A.print1B.print2C.print1 print2D.程序编译时出错
有如下程序: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; class TestClass 1 { public: TestClass 若有以下程序:include<iostream>using namespace std;class TestClass 1{public:TestClass1(){X=0;}int x;};class TestClass2:virtual public TestClass1{public:TestClass2(){x=10;}};class TestClass3:virtual public TestClass 1{public:TestClass3(){x=20;}};class TestClass4:public TestClass2, protected TestClass3{ };int main(){TestClass4 obj;cout<<obj.x<<end1;return 0:}该程序运行后的输出结果是______。
有如下程序: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 TestClass 下列程序的输出结果是( )。 #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=O; void fun(){TestClass ob2;cout<<ob2.getVal();} int main(){ TestClass ob1; fun(); TestClass*ob3=new TestClass;cout<<ob3->getVal(); delete ob3;cout<<TestClass::getVal(); return 0; }A.111B.121C.211D.221
有如下程序: #include(iostream) using namespace std; class TestClass{ protected: TestClass(){couti(cout<<‘x’;} TestClass(char c){cout<<c;}}; class TestClassl:publicTestClass{ public: TestClassl(char c){cout<<c;}}; int main(){ TeA.yB.yxC.xyD.yy
有如下程序: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 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
有下列程序:includeusing namespace std;class TestClass{protected:TestClass(){cou 有下列程序: #include<iostream> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char c){cout<<c;} }; class TestClassl:public TestClass{ public: TestClassl(char c){cout<<c;}A.yB.yxC.xyD.yy
有下列程序: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:publicTestClass { int b; public: TestClaA.5B.1C.0D.2
若有如下程序:includeusing namespace std;class TestClass{public:void who() {cout 若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who() {cout<<"TestClass"<<endl;} }; class TestClass1:public TestClass { public: void who(){cout<<"TestClass1"<<endl;} }; int main() { TestClass *p; TcstClass1 obj1; p=obj1; p->who(); return 0; } 则该程序运行后的输出结果是( )。A.TestClass1B.TestClassC.0D.无输出
有如下程序:includeusing namespace std;class TestClass{protected:TestClass(){co 有如下程序: #include<iost earn> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char C) {cout<<c;} }; class TestClass1:public TestClass { public: TestClass1(char C) {Cout<<c;) }; int main(){ TestClass1 d1('y'); return 0; } 执行这个程序,屏幕上将显示输出( )。A.yB.yxC.xyD.yy
有如下程序:includeusing namespace std;classTestClass{protected:TestClass(){cout 有如下程序: #include<iostream> using namespace std; classTestClass{ protected: TestClass(){cout<<'x';} TestClass(char c){cout<<c;} }; class TestClass1:public TestClass{ public: TestClass1(char C) {cout<<c;} }; int main(){ TestClass1 d1('y'); return 0; } 执行这个程序,屏幕上将显示输出( )。A.yB.yxC.xyD.yy