So I've made a class for a location,in which I store it's coordonates and it's time,in utc. I overloaded the >> operator like this
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;
}
and the << operator like this:
friend ostream& operator <<(ostream& out,const loc_list &l)
{
out << l.id << endl;
out << put_time(gmtime(&l.utc),"%c %Z" )<< endl;
//out << l.utc << endl;
out << l.p.getX() << endl;
out << l.p.getY() << endl;
out << l.speed;
return out;
}
however,the gmtime in the << operator works only when I create an object using the constructor. When I read it with cin>> it breaks. I've debugged the program but the objects contains the right data print from debugger
so,any thoughts?