c++,多项式的输入输出,什么问题啊?帮我调通,谢谢了

[复制链接]
查看11 | 回复1 | 2011-3-16 21:25:52 | 显示全部楼层 |阅读模式
#include
using namespace std;
class Term
{
public:
Term(int c,int e);
Term(int c,int e,Term *nxt);
Term* InsertAfter(int c,int e);
private:
int coef;
int exp;
Term *link;
friend ostream &operator>(istream &,constPolynominal &);
};
Polynominal::Polynominal()
//构造函数
{
theList=new Term(0,-1);
theList->link=theList;
}
Polynominal::~Polynominal() //析构构函数
{
Term* p=theList->link;
while(p!=theList)
{

theList->link=p->link;
delete p;
p=theList->link;

}
delete theList;
}
void Polynominal::AddTerms(istream & in)
{
Term *q=theList;
int c ,e;
for(;;)
{
cout>c>>e;
if(eInsertAfter(c,e);
}
}
void Polynominal::Output(ostream& out)const
//多项式的输出
{
int first=1;Term *p=theList->link;
coutlink)
{
if(!first&&(p->coef>0)) out>(istream& in,Polynominal &x)
{
x.AddTerms(in); return in;
}

/*void Polynominal::PolyMul(Polynominal& r)
{
}*/
void main()
//测试用例
{
Polynominal first,second;
cin>>first;
cout>second;
cout<<second;
}
--------------------Configuration: Polynominal - Win32 Debug--------------------
Compiling...
Polynominal.cpp
D:\编程练习\polynominal\Polynominal.cpp(125) : error C2593: 'operator <<' is ambiguous
D:\编程练习\polynominal\Polynominal.cpp(127) : error C2593: 'operator <<' is ambiguous
Error executing cl.exe.
Polynominal.exe - 2 error(s), 0 warning(s)

回复

使用道具 举报

千问 | 2011-3-16 21:25:52 | 显示全部楼层
#includeusing namespace std;class Term{public: Term(){}; Term(int c,int e); Term(int c,int e,Term *nxt); Term* InsertAfter(int c,int e); void Output(ostream& out) const;private: int coef; int exp; Term *link; friend ostream &operator<<(ostream &,const Term &); friend class Polynominal;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行