/*
*Daniel Tabuenca
*###-##-3128
*Login: dtabuenc
*Lab section 23
*Assignment 1
*Due April 28, Friday, 11:59pm, 2000
*/
#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
#include <iostream.h>
#include <stl.h>
#include <list>
#include "polyterm.h"
/*Typedef the STL-Linked List
*so that it is easier for us
*to refer to it.
*/
typedef list<PolyTerm> TermList;
/*Typdef an iterator for the TermList
*to make it easier to declare.
*/
typedef TermList::iterator TermListIterator;
class Polynomial
{
public:
/*Friend function to read polynomial
*data from a file or standard input.
*/
friend istream &operator>>(istream &,Polynomial &);
/*Friend function to output the polynomial back to a
*file or standard output.
*/
friend ostream &operator<<(ostream &, Polynomial &);
/*Overloaded operator to add two polynomials,
*the current one plus another one. Pay attention
*to the return value as it is a little counter
*intuitive. The function takes two objects but
*returns a pointer. This is because we are allocating
*a new Polynomial.
*/
Polynomial *operator+(Polynomial &);
/*Overloaded operator to multiply two polynomials
*same comment as above applies for return value.
*/
Polynomial *operator*(Polynomial &);
/*Operator to multiply an entire polynomial by
*one term.
*/
Polynomial *operator*(PolyTerm &);
private:
/*STL Linked list for storing the
*Polynomial.
*/
TermList terms;
void simplify();
/*Merges a Polynomial Array with n members
*to a smaller array of at most n/2 + 1 members
*by adding sequential polynomials into one.
*/
Polynomial **merge(Polynomial **);
};
#endif
syntax highlighted by Code2HTML, v. 0.8.11