C++ Polynomial Class

Feb 8, 2008 at 11:56am
In this program class name “Polynomial” which contains an array of size (n) not dynamic allocation, Degree of polynomial may be in a global variable, to store the coefficients of the polynomial into the indices corresponding to their powers. For example if we want to make a polynomial 2x4 + 3x3 – 12x2 + x – 19 (degree-4) then the polynomial class will have an array of the following form.
0 1 2 3 4

-19
1
-12
3
2


Main constructor which initizlie array to zero, member function mulftiply that take an integer, Add function that return Polynomial after adding, subtract. To test the polynomial in Main program.

I have written the following code. Please help me to complete this program.

#include <iostream.h>
#include <stdlib.h>
class Polynomial
{
protected:
int size[n];
public:
Polynomial(){}
//Constructor, which initializes the array to zero
Polynomial (int degree);
//Prints the polynomial in the following format, 2x^4+3x^3-12x^2+x-19
void outputPolynomial();
//Multiply a polynomial with the input scalar value.
//Returns a new Polynomial object, which is the resultant polynomial
//after the multiplication operation b=a.MulPolyWITHScalar(Value)means b=a*value
Polynomial MulPolyWithScalar(int value);
//Adds two polynomials of the same degree.
//Returns a new Polynomial object, which is the sum of polynomial of
//calling object and the "poly".
Polynomial AddPolynomials (Polynomial poly);
//Subtracts a polynomial from another of the same degree
//Example: b = a.SubtractPolynomials(poly) means b = a - poly
Polynomial SubtractPolynomials (Polynomial poly);

};
Polynomial::Polynomial (int degree)
{ for(int a=0;a=degree;a++)
size[a]=0;
}

void Polynomial::outputPolynomial()
{}

Polynomial Polynomial::MulPolyWithScalar(int value)
{}

Polynomial Polynomial::AddPolynomials (Polynomial poly)
{}

Polynomial Polynomial::SubtractPolynomials (Polynomial poly)
{}

int main()
{

Polynomail Poly;

system("PAUSE");
return 0;
}
Topic archived. No new replies allowed.