使用VC6打开考生文件夹下的工程test28_1,此工程包含一个源程序文件test28_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果为:
5
5
源程序文件test28_1.cpp清单如下:
#include <iostream.h>
class A{
public:
/***************** found *****************
static int n=1;
A(){n++;};
~A() (n--;};
};
/***************** found *****************
int n=0;
int main() {
A a;
A b[3];
A *c=new A;
c=&a;
/***************** found *****************
cout<<c.n<<end1;
cout<<A::n<<end1;
return 0;
}
【参考答案】
(1) 错误:static int n=1; 正确:static int n; (2) 错误:int n=0; 正确:i......