Reputation: 331
i have Polynomial class. i also have a method that take string and convert it to polynomial. now i try to implement this method for input operator:
istream& operator>> (istream &is, Poly& pol)
{
//the string that we use:
string str;
//the new input override the old:
pol.emptyPoly();
//getting a string from user and put it into str:
//?????????????????????
// convert the string to polynomial
pol.sToPol(str);
return is;
}
what am i need to put in //???????? to get the string from user and put it into str?
then when i will do:
Poly p1;
cin>>p1;
user will input string and it will be converted into polynomial in my method
Upvotes: 1
Views: 889
Reputation: 55897
is >> str;
if string is without spaces
std::getline(is, str);
if there are spaces in string.
Upvotes: 3