填空题
下列程序的输出结果是______。
#include<iostream)
using namespace Std;
Class Test
public:
Test()cnt++;
~Test()cnt--;
staticint 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()<<endl;
return 0;
【参考答案】
042。
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
类中包含了一个静态成员函数,则main函数中和P.f1(P);语句具有同样功能的语句为______。 #include<iostream.h> class M public: M(int A)A=a;B+=a; static void f1(M m); private: int A; static int B;; void M::f1(M m) cout<<“A=“<<m.A((end1; cout<<“B=”<<m.B<<end1; int M::B=10; void main() M P(5); P.f1(P);
点击查看答案&解析
填空题
对于下面定义的类MyClass,请在函数f()中添加对象成员把n的值修改为50。 Class MyClass Public: MyClass(int x)n=x;) Void SetNum(int nl)n=nl; private: int n; ; int f() MyClass*ptr=new MyClass(45);
点击查看答案&解析
相关试题
C++语句constchar *constp=”hello”...
在MyClass类的定义中,对赋值运算符=进行...
有以下程序: #include<iostream> usi...