-1

I am working on a project to solve a class in polynomial. I have successfully managed to do the header file and 75% of the code..but two functions to write and add the polynomials don't seem to work. Can someone help? The last part of the code!

```
#include <cassert>
#include <iostream>
#include "poly.h"
using namespace std;
#define NULL 0
const unsigned int poly::SIZEINCR = 5;
poly::poly()
{
variable = 'x';
nterms = 0;
terms = new term[MAXSIZE = SIZEINCR];
};
void poly::copy (const poly & p)
{
variable = p.variable;
nterms = p.nterms;
terms = new term[MAXSIZE = p.MAXSIZE];
for (unsigned int i=0; i<nterms; i++)
terms[i] = p.terms[i];
};
poly::poly (const poly & p)
{
copy (p);
};
void poly::free (void)
{
nterms = 0;
delete [] terms;
terms = NULL;
};
poly::~poly (void)
{
free ();
};
poly & poly::operator= (const poly & p)
{
if (this != &p)
{
free ();
copy (p);
};
return (*this);
};
void poly::expand ()
{
termptr p;
p = new term[MAXSIZE += SIZEINCR];
for (unsigned int j=0; j<nterms; j++) p[j] = terms[j];
delete [] terms;
terms = p;
};
void poly::InsertTerm (term t)
{
int i = nterms-1;
unsigned int e = t.exp;
if (nterms == MAXSIZE) expand ();
nterms++;
while ((i>=0) && (e > terms[i].exp))
{
terms[i+1] = terms[i];
i--;
};
assert ((i<0) || (e != terms[i].exp));
terms[i+1] = t;
};
void poly::read ()
{
poly temp;
int coeff;
int exp;
cout << "Input a polynomial by specifying the variable and all terms in any order." << endl
<< "Each term is specified by an integer coefficient and" << endl
<< "a non-negative integer exponent." << endl
<< "Indicate END by specifying a dummy term with" << endl
<< "a zero coefficient and/or a negative exponent." << endl;
cin >> temp.variable;
do
{
cin >> coeff;
if (coeff)
{
cin >> exp;
if (exp >= 0)
temp.InsertTerm (term(coeff, exp));
}
else
while (cin && (cin.peek() != '\n')) cin. ignore();
} while (coeff && (exp >= 0));
*this = temp;
};
void poly::write() const
{
// I need help!!!
};
poly poly::plus (const poly & right) const
{
};
poly poly::minus (const poly & right) const
{
};
float poly::evaluate (float value) const
{
};
```