我想在类中使用tm结构作为静态变量。花了一整天的时间阅读和努力,但仍然无法工作:(希望如果有人能指出我在做什么错初始化类中的静态结构tm
在我的课,公共下,我已宣布它为:
static struct tm *dataTime;
在main.cpp中,我试图定义和与系统时间初始化它暂时以测试(在运行时输入的实际时间)
time_t rawTime;
time (&rawTime);
tm Indice::dataTime = localtime(&rawTime);
但好像我不能用时间()外部功能
main.cpp:28: error: expected constructor, destructor, or type conversion before ‘(’ token
如何初始化类的静态tm中的值?
dataTime是'tm *'还是'tm'? – 2010-01-20 21:34:12
最好不要'tm *',因为'localtime'返回一个静态实例。 – 2010-01-20 21:35:14