下列程序输出结果为: include using namespace std; class TestClass1 { public: Test 下列程序输出结果为:include<iostream>using namespace std;class TestClass1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;};class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i;}void dispb(){dispa();cout<<"x2="<<x2<<endl;}private:int x2;};int main(){TestClass2 b(2);b.dispb();return 0;}

下列程序输出结果为: include using namespace std; class TestClass1 { public: Test

下列程序输出结果为:

include<iostream>

using namespace std;

class TestClass1

{

public:

TestClass1(){}

TestClass1(int i)

{

x1=i;

}

void dispa()

{

cout<<"x1="<<x1<<",";

}

private:

int x1;

};

class TestClass2:public TestClass1

{

public:

TestClass2(){}

TestClass2(int i):TestClass1(i+10)

{

x2=i;

}

void dispb()

{

dispa();

cout<<"x2="<<x2<<endl;

}

private:

int x2;

};

int main()

{

TestClass2 b(2);

b.dispb();

return 0;

}


相关考题:

有如下程序:includeusing namespace std;class test{private: int a;public: test( 有如下程序:#include<iostream>using namespace std;class test{private: int a;public: test(){cout<<"constructor"<<endl;} test(int a){cout<<a<<endl;} test(const test_test) { a=_test.a; cout<<"copy constructor"<<en+dl; } ~test(){cout<<"destructor"<<endl;}};int main(){ test A(3); rerun 0;}运行时输出的结果是A.3B.constructor destructorC.copy constructor destructorD.3 destructor

有下列程序: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 class test { private: int num; public: tes 下列程序的运行结果是【 】。include <iostream. h>class test{private:int num;public:test()int TEST() {return num+100;}~test()};test::test(){num=0;}test::~test(){cout<<"Destructor is active"<<endl;}void main(){test x[3]cout<<x[1]. TEST()<<endl;}

下列程序的运行结果是______。 include class test { private: int hum; public: tes 下列程序的运行结果是______。include<iostream.h>class test{private:int hum;public:test( );int TEST( ){return num+100;)~test( );};test::test( ){num=0;)test::~test( ){cout<<"Destructor is active"<<endl;)void main( ){test x[3];cout<<x[1].TEST( )<<endl;}

如下程序的输出结果是includeusing namespace std;class Test{public:Test( ){n+=2;} 如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} static int getNum( ){return n;} private: static int n; }; int Test::n=1; int main( ){ Test*P=new Test: delete P; cout<<"n="<<Test::getNum( )<<endl; return 0; }A.n=0B.n=1C.n=2D. n=3

请将下列程序的横线处补充完整,使得输出结果为bbaaincludeusing namespace std;class 请将下列程序的横线处补充完整,使得输出结果为bbaainclude<iostream>using namespace std;class A{public:______{cout<<"aa";}};class B:public A{public:~B(){cout<<"bb";}};int main(){B*p=new

请将如下程序补充完整,使得输出结果为:bbaa。 include using naluespace std; class 请将如下程序补充完整,使得输出结果为:bbaa。include<iostream>using naluespace std;class A{public:______{eout<<"aa";}};class B:public A{public:~B( ){eont<<"bb";}};int ulain( ){B*P=new B;delete P;return 0;}

下列程序的输出结果为2,横线处应添加语句()。includeusing namespace std;{public:___ 下列程序的输出结果为2,横线处应添加语句( )。 #include<iostream> using namespace std; { public: ______void fun(){cout<<1;} }; class TestClass2:public TestClass1 { public:void fun(){cout<<2;) }; int main() { TestClass1 *p=new TestClass2; p->fun(); delete p; Teturn 0; }A.publicB.privateC.virtualD.protected

下列程序的输出结果是______。 include using namespace std; class Test( public: Te 下列程序的输出结果是______。 #include<iostream> using namespace std; class Test( public: Test() {cnt++;} ~Test() {cnt--;} static int Count(){return cnt;} private: static int cnt; }; int Test::cnt=0; int main() { cout<<Test::Count()<<""; Test t1,t2; Test*pT3=new Test; Test*pT4=new Test; cout<<Test::Count()<<""; delete pT4; delete pT3; cout<<Test::Count()<<end1; return 0; }A.024B.042C.420D.240