![]() |
#2
sunflower442011-09-04 17:36
|

class Test{
public:
Test(){a=0;c=0;} //1
int f(int a)const{this->a=a;} //2
static int g(){return a;} //3
void h(int b){Test::b=b;} //4
private:
int a;
static int b;
const int c;
};
int Test::b=0;
我只感觉4错了额,静态数据成员只能被初始化一次。public:
Test(){a=0;c=0;} //1
int f(int a)const{this->a=a;} //2
static int g(){return a;} //3
void h(int b){Test::b=b;} //4
private:
int a;
static int b;
const int c;
};
int Test::b=0;
还有哪几行是错的?请教各位哈,这是二级C++模拟题中的一道
[ 本帖最后由 sunflower44 于 2011-9-4 17:34 编辑 ]