问题
填空题
#include<iostream.h>
class test
private:
static int x;int y;
public:
void test1(int a,int b)x=a;y=b;
;
void main()
test a;
a.test1(2,3);
答案
参考答案:{x=a;y=b;};
解析:在类的非静态函数中不可直接访问类的静态成员
#include<iostream.h>
class test
private:
static int x;int y;
public:
void test1(int a,int b)x=a;y=b;
;
void main()
test a;
a.test1(2,3);
参考答案:{x=a;y=b;};
解析:在类的非静态函数中不可直接访问类的静态成员