![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
istream& operator>>(istream&s, complex &a) // returns istream& so can be chained
{
double re=0, im=0;
char c=0;
s>>c;
if (c== '(') {
s>>re >> c;
if (c == ',') s >> im >> c;
if (c != ')') s.clear(ios_base::badbit);
}
else {
s.putback(c);
s>> re;
}
if (s) a = complex(re,im);
return s;
}