【发布时间】:2012-02-20 07:16:37
【问题描述】:
来自http://www.learncpp.com/cpp-tutorial/812-static-member-functions/的代码示例:
class Something
{
private:
static int s_nValue;
};
int Something::s_nValue = 1;
此代码编译时不会出现警告或错误。我不明白为什么。
我们不应该因为尝试访问s_nValue 而收到警告,因为它是私有的吗?还是这些访问说明符不适用于静态成员?
【问题讨论】: