[问题] 建构子问题

楼主: pujols05 (qq)   2014-06-21 20:15:12
class Time
{
public:
Time(){count=999;}
static int howmany(){count++;return count;}
private:
static int count;
};
int _tmain(int argc, _TCHAR* argv[])
{
Time x;
cout<<x.howmany()<<endl;
//cout<<Time::howmany()<<endl;
system("pause");
return 0;
}
请问一下各位 这里我将count设成静态为什么会出现错误?
还有这行 cout<<Time::howmany()<<endl;
::这里是什么意思? 这行编译有过不了
作者: lNishan (紫小霓)   2014-06-21 22:30:00
Static Member要先initialize哦
作者: steve1012 (steve)   2014-06-22 09:36:00
要init

Links booklink

Contact Us: admin [ a t ] ucptt.com