【C++问题:定义一个多项式类Polynomial,其实例为多项式:a0+a1x+a2x2+...+anxn定义一个多项式类Polynomial,其实例为多项式:a0+a1x+a2x2+...+anxn,该类具有如下的接口:classPolynomial{.public:Polynomial();Polynomial】
C++问题:定义一个多项式类Polynomial,其实例为多项式:a0+a1x+a2x2+...+anxn
定义一个多项式类Polynomial,其实例为多项式:a0+a1x+a2x2+...+anxn,该类具有如下的接口:
classPolynomial
{.
public:
Polynomial();
Polynomial(doublecoefs[],intexps[],intsize);
//系数数组、指数数组和项数
Polynomial(constPolynomial&);
Polynomial();
Polynomial&operator=(constPolynomial&);
intdegree()const;//最高幂指数
doubleevaluate(doublex)const;//计算多项式的值
booloperator==(constPolynomial&)const;
booloperator!=(constPolynomial&)const;
Polynomialoperator+(constPolynomial&)const;
Polynomialoperator-(constPolynomial&)const;
Polynomialoperator*(constPolynomial&)const;
Polynomial&operator+=(constPolynomial&);
Polynomial&operator-=(constPolynomial&);
Polynomial&operator*=(constPolynomial&);
};