问题
填空题
使用VC++6.0打开考生文件夹下的源程序文件1.cpp,但该程序运行有问题,请改正main()函数中的错误,使该程序的输出结果正确。
程序输出:
8
8
注意:错误的语句在/********found********/的下而。修改该语句即可,其他的语句不能修改。
试题程序:
#include<iostream.h>
class C0
public:
/********error********/
static int n=0;
C0()
n++;
~C0()
(
n--;
;
/********error********/
int C0::n;
void main()
Co obj;
CO obj2[7];
C0 *C=NULL;
c=&obj;
/********error********/
cout<<c.n<<end1;
tout<<C0::n<<end1;
答案
参考答案:“static int n=0”应改为“static int n;”。