Odanaga 0 Newbie Poster

I wrote this program to make a linked list that holds a polynomial, which I then use in various operations. However, the program will not run at all. It builds correctly, but when I try to run it, it will either not come up at all, or it will come up and then immediately crash. Can anybody tell me what I've done wrong?

#include <iostream>
#include <math.h>
using namespace std;



typedef int ElementType;


class Polynomial
{
private:
class Node
{
public:
ElementType coef;
ElementType exp;
Node * next;

Node()
{
Node* next1 = NULL;
coef = 0;
exp = 0;
next = next1;

};

int getCoef()
{
return coef;

};

int getExp()
{
return exp;

};

void setCoef(int a)
{

coef = a;
};

void setExp(int a)
{
exp = a;

};



};


typedef Node* NodePointer;


public:
Polynomial(ElementType a, ElementType b)
{
first = NULL;
Node * temp = new Node;

temp -> coef = a;
temp -> exp = b;

first = temp;
last = temp;
mySize = 6;
};

void insert(ElementType a, ElementType b)
{

Node * temp1;
temp1 = new Node;

while (temp1 -> next != NULL)
temp1 = temp1 -> next;
temp1 -> coef = a;
temp1 -> exp = b;

last = temp1;



};

void output()
{
int x;
int a = 0;
int b = 0;

for (x = 0; a > x && first -> next != NULL; x++)
{
a = first -> getCoef();
b = first -> getExp();

cout << "The numbers are " << a << " " << b << endl;


};
};

int outCoef()
{
	return first->getCoef();
};

int outExp()
{
	return first->getExp();
};

int outSize()
{
	return mySize;
};

void traverse(int a)
{
int x;
for (x = 0; a > x && first -> next != NULL; x++)
{
first = first -> next;

};
};


bool empty()
{
if (first == NULL)
{
return true;
};

if (first != NULL)
{
return false;

};


};

void deletion()
{
int x;
for (x = 0; mySize > x; x++)
{
while (first -> next != NULL)
first = first -> next;

delete first;

};


};

Polynomial & operator= (Polynomial & other)
{
if (this != &other)
{
int x;
int a = 0;
int b = 0;

other.deletion();


for (x = 0; mySize > x && first -> next != NULL; x++)
{

a = first -> getCoef();
b = first -> getExp();

other.insert(a,b);

first = first -> next;

};

};


};

double evaluation(double x)
{
	double a, b;
	a = first->getCoef();
	b = first->getExp();
    double result = pow(x,b);
	double result2;
	result = result*a;
	for (int y = 0; mySize > y && first->next == NULL; y++)
	{
		first =  first->next;
		a = first->getCoef();
		b = first->getExp();
		result2 = pow(x,b);
		result2 = result*a;
		result = result + result2;	
	};
	return result;
};

void addition(Polynomial & other)
{
	int a = first->getCoef();
	int b = first->getExp();
	int x = other.outCoef();
	int y = other.outExp();
	int result;
	for (int z = 0; mySize > z && first->next !=NULL; z++)
	{
		if (b == y)
		{
			result = a+x;
			cout << result <<"^" << b << " + ";
		}
		else
		{
			for (int foo = 1; other.outSize() > foo; foo++)
			{
				other.traverse(foo);
				int x = other.outCoef();
				int y = other.outExp();
				if(b==y)
				{
					result = a+x;
					cout << result <<"^" << b << " + ";
				}
			}

			first=first->next;
			a = first->getCoef();
			b = first->getExp();
		};
	}
};
~Polynomial()
{
int x;

for (x = 0; mySize > x; x++)
{
while (first -> next != NULL)
first = first -> next;

delete first;

};

};







private:

NodePointer first;
NodePointer last;
int mySize;




};



int main()
{
Polynomial dog(10,2);
dog.output();

return 0;

};