polynomial class

hi, can you help me in writing the functions for this program please?!

"Design a class to perform various Polynomial operations. A polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. A polynomial in one variable (i.e., a univariate polynomial) with constant coefficients is given
by (n: degree and an, an-1,…a2,a1 :the coefficients).
Design and implement a class called Polynomial that can store a polynomial of any degree (dynamic allocation).
Your class should have the following attributes:
 int variable that contain the degree of the polynomial.
 Dynamic array of integers to store the coefficients of the polynomial.
For this class you must provide the following member functions:
 A parametrized constructor to dynamically allocate the polynomial of N degree. The constructor should take an integer value that represent degree as parameter.
 Destructor that frees all dynamically allocated array.
 Overload the operators +, -, * and = = to perform the addition, subtraction,
Multiplication, and comparison operations, respectively.
 Overload the operators >> to insert a polynomial and << to output a polynomial.
Also, write a test program to test various operations on polynomial."
Sure we will help you, but you have to start first.
Start with the first task:
Your class should have the following attributes:
int variable that contain the degree of the polynomial.
#include<iostream>
#include<string>
#include<cmath>

using namespace std;



class Polynomial
{
int degree;
int *coeff[10];


public:
Polynomial(int n)
{degree=n;}

~Polynomial()
{delete []coeff;}

void setdegree(int d)
{degree=d;}
int getdegree()
{return degree;}

const Polynomial operator+ (const Polynomial &) const;
const Polynomial operator+ (double) const;
friend const Polynomial operator+ (double, const Polynomial &);

const Polynomial operator- (const Polynomial &) const;
const Polynomial operator- (double) const;
friend const Polynomial operator- (double, const Polynomial &);


const Polynomial operator* (const Polynomial &) const;
const Polynomial operator* (double) const;
friend const Polynomial operator* (double, const Polynomial &);

friend ostream & operator<< (ostream &, const Polynomial &);
















};










void main()
{



}
i already started with this ! im sorry i didnt post my solution first .
thanks for offering help anyway!
Why this int *coeff[10]; ?

Imagine sth like this f(x) = 3x2 - 2x + 1
degree would be 2
coeff[0] = 1
coeff[1] = -2
coeff[2] = 3

Also your setdegree function isn't needed. You supply the degree in the ctor and that's enough.
You rather need a setter for the coeffs.
Topic archived. No new replies allowed.