首页 > > > Effective C++ 条款2的疑问?
1 class GamePlayer
2 {
3 public:
4 static const int NumTurns = 5;
5 int scores[NumTurns];
6 };
7 int main()
8 {
9 const int *pint = &GamePlayer::NumTurns;
10 cout << *pint << endl;
11
12 system("pause");
13 }书上说你所看到的是NumTruns的声明而非定义式,而且不去地址的话就不用定义,如果取地址的话就额外定义。但是我在main中取地址也没有错误啊?这是为什么啊?是我那个地方理解错误了?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4809/viewspace-3150718/ ,如需转载,请注明出处,否则将追究法律责任。