C++ gmtime赢得';对于使用重载运算符读取的对象,t不起作用
因此,我为一个位置创建了一个类,我在其中以utc存储它的坐标和时间。我像这样重载了>>操作符C++ gmtime赢得';对于使用重载运算符读取的对象,t不起作用,c++,oop,time,time-t,C++,Oop,Time,Time T,因此,我为一个位置创建了一个类,我在其中以utc存储它的坐标和时间。我像这样重载了>>操作符 friend ifstream& operator >>(ifstream& in, loc_list& l) { char bf[40]; in >> bf; l.setID(bf); long t=0; in >> l.utc; //l.setTime(t); double point
friend ifstream& operator >>(ifstream& in, loc_list& l)
{
char bf[40];
in >> bf;
l.setID(bf);
long t=0;
in >> l.utc;
//l.setTime(t);
double point;
in >> point;
l.p.setX(point);
in >> point;
l.p.setY(point);
in >> l.speed;
return in;
}
与
put\u time
相对应的
我建议使用:
std::tm tm
in >> get_time(&tm, "%c %Z");
然后从tm
更新l.utc
l.utc = mktime(&tm);
它是如何中断的,具体在哪里中断的?它在这里中断,我不能像那样读取时间,因为在我的输入文件中,时间看起来是这样的1439467748512@RamonaMihaelaDinescu,我尝试在一个简单的程序中测试功能,但我尝试的编译器似乎不支持
std::put_time
或std::get_time
。你可以在你的环境中尝试一下。链接:。
l.utc = mktime(&tm);