使用VC6打开考生文件夹下的工程test39_1,此工程包含一个源程序文件test39_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为;
This is static a: 1
This is non-static b: 1
This is static a: 2
This is non-static b: 2
This is static a: 2
This is non-static b: 1
Press any key to continue
源程序文件test39_1.cpp清单如下;
#include<iostream.h>
class shared
{
static int a;
int b;
public:
/***************** found *****************/
void set(int i=0, int j) {a=i; b=j;}
void show();
};
/***************** found *****************/
void shared::show()
{
cout << "This is static a: "<< a;
cout << "\nThis is non-static b: " << b;
/***************** found *****************/
cout >> "\n";
}
void main ()
{
shared x, y;
x.set (1, 1);
x.show ( );
y.set (2, 2);
y.show ( );
x.show ( );
}