我有多项式类。我也有一个方法,把字符串转换成多项式。现在我尝试为输入操作符实现这个方法:
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;
}
我需要在//????????中放入什么从用户获取字符串并把它放入str?
then when I will do:
Poly p1;
cin>>p1;
用户将输入字符串,它将在我的方法中转换为多项式
is >> str;
如果字符串没有空格
std::getline(is, str);