我遇到了这个代码示例,我记得之前看到过它,但不知道它的作用和功能是什么?我在互联网上搜索了一下,但没有找到相关信息。
代码:
最后一个类括号后的
代码:
class C
{
int x; // a non-static variable, implicitly private
public:
C() : x(0) {} // default constructor
// a static member function, which uses a non-static variable perfectly well
static int Incr(C& instance) { return ++(instance.x); }
} g_c;
int main(void)
{
C c2;
return C::Incr(g_c) + C::Incr(c2);
}
最后一个类括号后的
g_c
是什么意思?