Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ gmtime赢得';对于使用重载运算符读取的对象,t不起作用_C++_Oop_Time_Time T - Fatal编程技术网

C++ gmtime赢得';对于使用重载运算符读取的对象,t不起作用

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

因此,我为一个位置创建了一个类,我在其中以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;
    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);