[問題] 建構子問題

作者: 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