( 29 ) 有如下程序 :#includeusing namespace std;class Obj{static int i;public:Obj( ){ i++; }~Obj( ){ i--; }static int getVal( ){ return i;}};int Obj::i=0;void f(){Obj ob2; coutint main( ){Obj ob1;f( );Obj *ob3=new Obj; coutgetVal( );delete ob3; cout return 0;}程序的输出结果是A ) 232B ) 231C ) 222D ) 221
( 29 ) 有如下程序 :
#include
using namespace std;
class Obj{
static int i;
public:
Obj( ){ i++; }
~Obj( ){ i--; }
static int getVal( ){ return i;}
};
int Obj::i=0;
void f(){Obj ob2; cout<
int main( ){
Obj ob1;
f( );
Obj *ob3=new Obj; cout<getVal( );
delete ob3; cout< return 0;
}
程序的输出结果是
A ) 232
B ) 231
C ) 222
D ) 221
相关考题:
有如下程序#includeusing namespace std;class Obj{static int i;public:Obj(){i++;}~Obj(){i--;}static int getVal(){teturn i;}};int Obj::i=0;void f (){Obj ob2;coutObj obl;F();Obj*ob3=new Obj;coutDelete ob3;cout}程序的输出结果是______。A.232B.231C.222D.221
以下程序的执行结果是【】。 include using namespace std; class base { public: virmal 以下程序的执行结果是【 】。include<iostream>using namespace std;class base{public:virmal void who(){cout<<"Base Class"<<endl;)};class Derivedl:public Base{public:virtual void who(){cout<<"Derivedl Class"<<endl;}};class derived2:public Base{public:virtual void who(){cout<<"Derived2 Class"<<endl;)};int main(int argc,char*argv[]){base obj1,*P;deliVedl obj2;derived2 obj3;p=obj1; p->who();p=obj2; p->who();p=obj3; p->who();return 0;}
有如下程序: include using namespace std; class Obj { static in 有如下程序: #include <iostream> using namespace std; class Obj { static int i; public: Obj( ){i++;} ~Obj(){i--;} static int getVal( ){ return i;} }; int Obj::i=0; void f() {Obj ob2; cout<<ob2.getVal( ); } int main( ){ Obj ob1; f(); Obj *ob3=ew Obj; cout<<ob3->getVal( ); delete ob3; cout<<Obj::getVal( ); return 0; } 程序的输出结果是A.232B.231C.222D.221
有如下程序: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
有如下程序:include using namespace std;class Obj { static int i;public:Obj(){i+ 有如下程序:#include <iostream>using namespace std;class Obj { static int i;public: Obj(){i++;} -Obj(){i--;} static int getVal(){return i;} };int Obj::i=0;void f(){Obj ob2; cout<<ob2.getVal(); }hat main(){ Obj ob1; f(); Obj *ob3=new Obj; cout<<ob3->getVal(); delete ob3; cout<<Obj:: getVal(); return (); }程序的输出结果是( )。A.232B.231C.222D.221
以下程序的执行结果是______。 include class base { public: virtual void who(){c 以下程序的执行结果是______。include<iostream.h>class base{public:virtual void who(){cout<<"base class"<<endl:}};class derrvel:public base{public:void who(){cout<<"derivel class"<<endl:}};class derive2;public base{public:void who() {cout<<"derive2 class"<<endl;}};void main(){base obj1,*P;derive1 obj2;derive2 obj3:p=obj1;p->who();p=obj2:p->who();p=obj3;p->who();}
有如下程序: #includeiostream using namespace std; class Obj{ static int i; public: Obj{i++;} 一Obj{i一一;} static int getVal{return i;} }; int Obj::i=0: void f{Obj ob2;coutob2.getVal;} int main{ Obj obl; f; Obj}ob3=new Obj;coutob3一getVal; delete ob3;coutObj::getVal; return 0; } 执行这个程序的输出结果是( )。A.232B.231C.222D.221
有以下程序:include using namespace std;class Base{public:Base(){}virtual void w 有以下程序: #include <iostream> using namespace std; class Base { public: Base(){} virtual void who() { cout<<"Base Class"<<end1; } ~Base(){} }; class Derivel : public Base { public: void who() { cout<<"Derivel Class"<<end1; } }; class Derive2 : public Base { public: void who () { cout<<"Derive2 Class"<<end1; } }; int main () { Base *p; Derivel obj1; Derive2 obj2; p=obj1; p=obj2; p->who ( ); return 0; } 执行程序后的输出结果是( )。A.Base ClassB.Derivel ClassC.Derive2 ClassD.程序编译时出错
type(obj) 函数为返回参数obj的类型,eval(obj)函数负责将obj两侧的一对单/双引号去除,则type(eval('"45"'))的结果为A.45B.<class 'int'>C.<class 'str'>D.None