The following set of 3 files compile just fine when it is one program and I DO NOT use a class. When I broke it up into 3 files my compiler gets very angry with me.
The program sorts using linked lists( at least it does without the class and 3 files)
I looked up the error in the MS Knowledge base but do not understand what it means:
http://support.microsoft.com/default...b;en-us;226110
I am using MS Visual C++ 6.0 on Windows XP. When I compile I get the following error:
Code:
--------------------Configuration: aaa - Win32 Debug--------------------
Compiling...
qwert.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\aaa\qwert.cpp(14) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
qwert.obj - 1 error(s), 0 warning(s)
I have the following 3 files:
FILE1: main.cpp
Code:
#include"qwert.h"
#include<iostream.h>
void main ()
{
sort sortClass;
node* head;
char i;
cout << "Enter first letter (0 to stop): ";
cin >> i;
while(i != 'z')
{
head = sortClass.sortedinsert(head, i);
cout << "Enter next letter (0 to stop): ";
cin >> i;
}
cout << "You entered these letters:" << endl;
sortClass.displaylist(head);
}
FILE2: qwert.cpp
Code:
#include"qwert.h"
#include<iostream.h>
//----------------------------------------------
sort::sort()
{
cout << "Constructor Called" << endl;
head = NULL;
}
//----------------------------------------------
sort::~sort()
{
cout << "Destructor Called" << endl;
delete head;
head = NULL;
}
//----------------------------------------------
void sort::displaylist(node*& head_ptr)
{
while(head_ptr != NULL)
{
cout << head_ptr->data << " ";
head_ptr = head_ptr->next;
}
cout << endl;
}
//----------------------------------------------
node* sort::sortedinsert(node*& head, char data)
{
node *newNode;
// populate the new node that we're adding.
newNode = new node;
newNode->data = data;
newNode->next = NULL;
// figure out where to add that node in
if((head == NULL) || (head->data >= newNode->data))
{
// this element should go at the head of the list
newNode->next = head;
head = newNode;
}
else // this is not the first element in the list
{
// create a pointer that will traverse the list to find where to insert the new element
node* current;
current = head;
// move current down the list till we find where our new node is supposed to go
while((current->next != NULL) && (current->next->data < newNode->data))
{
current = current->next;
}
newNode->next = current->next;
current->next = newNode;
}
return head;
}
FILE3: qwert.h
Code:
struct node
{
char data;
node* next;
};
//----------------------------------------------
class sort
{
private:
node* head;
public:
sort();
~sort();
void displaylist(node*& head);
node* sortedinsert(node*& head, char data);
};
I hope someone knows what I am doing wrong.