So not the overloaded operator itself, but in its function body (Whatever you call it). For example:
std::istream& operator>>(std::istream& in, std::vector<queryPoint>& queryPoints)
{
queryPoint point;
in >> point.x2;
in >> point.y2;
in >> point.name;
queryPoints.push_back(point);
return in;
}
Here is a snippet of code that will take in input from an external file, and will pass the first three inputs into an integer, another integer, and a string. I would like to catch an error if the file inputs a string, or a char, or any input error, into my point.x2
or point.y2
, if that makes sense. How could I do this? I would also like to send out an error message, and terminate the program. Do I also have to reset the input stream, like I have to do with std::cin.clear()
and std::cin.ignore(10000, '\n')
?
Thanks in advance.