下列程序的输出结果为( )。 #includeiostream.h classTestClass { public: TestClass(){val++;} static,intval; }; intTestClass::val=0; voidmain() { TestClasscsl; coutcsl.val""; TestClasscs2; TestClasscs3,cs4; coutcs2.valendl; }A.O3B.13C.14D.24
下列程序的输出结果为( )。 #include<iostream.h> classTestClass { public: TestClass(){val++;} static,intval; }; intTestClass::val=0; voidmain() { TestClasscsl; cout<<csl.val<<""; TestClasscs2; TestClasscs3,cs4; cout<<cs2.val<<endl; }
A.O3
B.13
C.14
D.24
相关考题:
有如下程序: 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 ():}这个程序的输出结果是______。
以下程序输出结果为______。 include using namespace std; class TestClass 1 { publi 以下程序输出结果为______。include<iostream>using namespace std;class TestClass 1{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<<end1;}private:int x2:}:int main(){TestClass2 b(2):b.dispb();return 0;}
有下列程序: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;
有如下程序: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
执行下列程序的输出结果是______: include using namespace std; class TestClass1 { 执行下列程序的输出结果是______:include<iostream>using namespace std;class TestClass1{public:void fun1(){cout<<"TestClass1\n";}virtual void fun2(){cout<<"TestClass1\n";}};class TestClass2:public TestClass1{public:void fun1(){cout<<"TestClass2\n";}void fun2(){cout<<"TestClass2\n";}};void f(TestClass1b)<b.fun1();b.fun2();}int main(){TestClass2 obj;f(obj);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;}
若有以下程序: 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; 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{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{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; TestClass1 obj1; P=obj1; P->who(); return 0; 则该程序运行后的输出结果是( )。A.TestClass1B.TestClassC.0D.无输出