I was making an
class object{
//data...
public:
friend std::istream& operator>>(std::istream & in,object & o)
{ char
c,
d
;
in>>c>>d;
if(c==d){
/*set the fail bit some how*/
in.putback(d);
in.putback(c);
}
else o.set_data(c,d);
return in;
}
}
I was looking at the documentation (not well) but couldn't find a proper way to set the fail bit. The reason I care is I'd like to be able to while(std::cin>>obj)/*do stuff*/;
like one can do with an int. But if I currently do this there would be an infinite loop any time there was an error. -_-
Is setting the fail bit possible or am I going to have to work with this problem a different way?
Aucun commentaire:
Enregistrer un commentaire