填空题
下列程序的输出结果是______。
#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*oT3=new Test;
Test*pT4=new Test;
cout<<Test::Count()<<’’;
delete pT4;
delete pT3;
cout<<Test::Count()<<endl;
return 0;
【参考答案】
042
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
下面程序的运行结果是______。 #include<iostream> using namespace std; class count static int n; public: count() n++; static int test() for(int i=0;i<4;i++) n++; return n; ; int count::n=0; int main() cout<<count:: test()<< ; count c1, c2; cout<<count :: test()<<endl; return 0;
点击查看答案&解析
填空题
将一个函数声明为一个类的友元函数必须使用关键字______。
点击查看答案&解析
相关试题
下面程序的执行结果是______。 #in...
有以下程序: #include<iostream> usi...
Staff类含有血型数据成员ID,两个Staff对象...
虚函数必须是类的______。
下列程序的输出结果是______。 #in...