I am having a compiler error that causes a screen to pop up that says break or continue. I know it is something wrong with my program but I am at a lost as to what it is. I was just trying to test the first function as you can see from my main program at the bottom. Any help would be deeply appreciated I have been working non stop on this for days and haven't figured it out.
Here is my header file:
#include <iostream>
using namespace std;
struct Node
{
char cvalue;
double dvalue;
int keyvalue;
Node *next;
};
Here is my .cpp file
#include "SimplelinkedListLab_2.h"
class SimpleLinkedList
{
private:
Node *first; // This is the only member variable your are allowed!
public:
SimpleLinkedList(); // Default constructor
~SimpleLinkedList(); // Destructor must delete all nodes in the list
bool empty();// returns true if list is empty
void insert (char, double, int);
void remove(int);
int listCount();
bool getValue(int, char & c, double & d);
void minValue( char & cval, double & dval);
void maxValue(char & cval, double & dval);
void displayList( ostream & out);
};
SimpleLinkedList ::SimpleLinkedList()
{
first = new Node;
first -> next = NULL;
}
SimpleLinkedList :: ~SimpleLinkedList()
{
Node *temp = new Node;
while (first != NULL)
{
temp = first -> next;
delete temp;
}
}
bool SimpleLinkedList :: empty()
{
if (first -> next == NULL)
return true;
else
return false;
}
void SimpleLinkedList :: insert( char c, double d, int key)
{
char cvalue = c;
double dvalue = d;
int keyvalue = key;
Node *tmp = new Node;
tmp -> dvalue = dvalue;
tmp -> cvalue = cvalue;
tmp -> keyvalue = keyvalue;
if (tmp == NULL)
return;
if (first == NULL || key < first -> keyvalue)
{
tmp -> next = first;
first = tmp;
}
else
{
Node *pred = first;
while (pred -> next != NULL && pred -> next -> keyvalue < key)
{
pred = pred -> next;
}
tmp -> next = pred -> next;
pred -> next = tmp;
}
delete tmp;
}
void SimpleLinkedList :: remove(int key)
{
Node *pred = NULL;
Node *tmp = first;
if (tmp == NULL)
return;
if (tmp -> keyvalue == key)
{
first = tmp -> next;
delete tmp;
return;
}
tmp = tmp -> next;
while (tmp != NULL && tmp -> keyvalue != key)
{
pred = tmp;
tmp = tmp -> next;
}
if (tmp != NULL)
{
pred -> next = tmp -> next;
delete tmp;
}
}
int SimpleLinkedList :: listCount()
{
Node *tmp = first;
int count = 0;
while (tmp -> keyvalue != NULL)
{
count++;
}
delete tmp;
return count;
}
// Returns the number of nodes in the list.
void SimpleLinkedList :: displayList( ostream & out)
{
Node *tmp = first;
while(tmp != NULL)
{
out << tmp -> cvalue << " ";
out << tmp -> dvalue << " ";
out << tmp -> keyvalue << " ";
tmp = tmp -> next;
}
cout << endl;
}
bool SimpleLinkedList :: getValue(int key, char & c, double & d)
{
Node *tmp = first;
while (tmp != NULL && tmp -> keyvalue != key)
{
tmp = tmp -> next;
}
c = tmp -> cvalue;
d = tmp -> dvalue;
if (tmp == NULL)
return false;
else
return true;
}
void SimpleLinkedList :: minValue( char & cval, double & dval)
{
Node *tmp = first;
int min = cval;
double dmin = dval;
while (tmp != NULL)
{
if (cval > tmp -> cvalue)
tmp = tmp -> next;
else
min = cval;
}
delete tmp;
Node *tmp2 = first;
while (tmp != NULL)
{
if (dval > tmp -> dvalue)
tmp = tmp -> next;
else
dmin = dval;
}
delete tmp2;
}
void SimpleLinkedList :: maxValue(char & cval, double & dval)
{
Node *tmp = first;
int max = cval;
double dmax = dval;
while (tmp != NULL)
{
if (cval > tmp -> cvalue)
tmp = tmp -> next;
else
max = cval;
}
delete tmp;
Node *tmp2 = first;
while (tmp != NULL)
{
if (dval > tmp -> dvalue)
tmp = tmp -> next;
else
max = dval;
}
delete tmp2;
};
int main ()
{
SimpleLinkedList list;
list.insert('A', 1, 1);
list.displayList(cout);
system ("PAUSE");
}
Again any help would be much appreciated