1
我有多项式类。我也有一种方法可以将字符串转换为多项式。 现在我试图实现输入操作此方法:获取字符串只在超载>>运算符istream:
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?
然后当我将做:
Poly p1;
cin>>p1;
用户将输入字符串,如果字符串是没有空格它将被转换成多项式在我的方法
谢谢,但它不工作。 第一个灵魂给我错误: 错误C2678:二进制'>>':没有找到操作符,它需要类型'std :: istream'的左侧操作数(或没有可接受的转换) 第二个不找到getline std – 2013-04-23 09:58:03
@AviadChmelnik怎么样#include? –
ForEveR
2013-04-23 10:08:43
我试图编辑评论:“我的错误!,忘了写包括字符串”但5分钟的编辑结束了。 非常感谢很多人!你可以在“OOP简介”中保存我的成绩:) – 2013-04-23 10:23:11