linked lists help please!
Does this look right to you? When I run it, it goes through. No syntax errors. But when I try to declare objects in main on the heap and stack I get an "internal compiler" error. I'm 95% sure that these functions are fine so it must be something in my main. The first function adds a node to the list. The other functin deletes a node. The error says "internal compiler error at [insert some random memory address]"..Generally speaking, what does this error mean? Here is the code:
edit: the error -[C++ Fatal Error] Unit1.cpp(32): F1004 Internal compiler error at 0xc9e04b2 with base 0xc9d0000; I'm using borland
Thank you in advance for any assistance :)
edit: the error -[C++ Fatal Error] Unit1.cpp(32): F1004 Internal compiler error at 0xc9e04b2 with base 0xc9d0000; I'm using borland
Thank you in advance for any assistance :)
//specification file
#include "theatre.h"
#include
#include
void TheatreList::insertNode()
{
string patronName;
int seatNum;
cout<<"enter name:"<<endl;
getline(cin,patronName);
cout<<"enter seat number:"<<endl;
cin>>seatNum;
SeatNode * stalker=NULL, *walker=firstPtr;
while(walker!=NULL)
{
if(walker->patronName >= patronName)
break;
stalker = walker;
walker = walker->link;
}
if(walker!=NULL && walker->patronName==patronName)
cout<<"patron already exists"<<endl;
else
{
SeatNode * builder= new SeatNode;
assert(builder!=0);
builder->patronName = patronName;
builder->seatNum = seatNum;
builder->link = walker;
if(walker==firstPtr)
firstPtr=builder;
else
stalker->link=builder;
cout<<"reserved"<<endl;
}
}
void TheatreList::deleteNode(int seatNum)
{
SeatNode * walker = firstPtr;
SeatNode * stalker = NULL;
while(walker!=NULL)
{
if(walker->seatNum == seatNum)
break;
stalker=walker;
walker=walker->link;
}
if(walker==NULL)
cout<<"seat not found";
else
{
if(firstPtr==walker)
firstPtr=walker->link;
else
stalker->link=walker->link;
delete walker;
cout<<"deleted";
}
//main
#include "theatre.cpp"
#include
using namespace std;
int main()
{
TheatreList patron(44,"cats");
patron.displayAll();
patron.insertNode();
patron.insertNode(); //I think this is what is causing the error...hmm
}
