temp = new(nothrow)Node; // allocate space for a new
// node and store its address in temp
temp->data = data; // copy the data over into
// the new node
temp->link = NULL; // and this new node is
// not pointing at any other node
// is the linked list empty?
if(top == NULL) {
// if so this new node is the first node into the linked list
top = temp;
rear = temp;
}
else
{ // else already
// have some nodes in the linked list
rear->link = temp; // the last node; link
// it to the new node
rear = temp; // now make this new
// node the last node
}
count++; // shows that we have added one more node
}
// function to look for a node; given a key, search for it in the linked list
// and return the node found in dataOut
bool LList::SearchLList(Node &nodeOut,int key)
{
Node *temp;
bool retFlag= false; // determines the
//result of the search
temp = top;
while(temp != NULL) { // start from the beginning node in the
// linked list
if(temp->data.key == key) {
retFlag = true;
nodeOut = temp;
break; // break
//out of the while loop
}
temp = temp->link; // let us look at the
// next item
}
return retFlag;
}
// function to remove a node from the list; we search for a node whose key
// value matches the keyIn
bool LList::RemoveItem(int key)
{
Node *nodeOut; // will contain address of
// the node to remove
bool retFlag;
char resp;
retFlag = SearchLList(nodeOut,key);
if(retFlag == true) { // we were able to find the node
cout << "Key: " << nodeOut->key << " Name: " << nodeOut->name
<< "\n";
cout << "\n\nDo you really want to remove this node? (Y/N): ";
cin >> resp;
//--- delete node -----
}
// free the memory held up by the linked list
void LList::freeLLMemory()
{
Node *temp = top; // gets the address of the first item on
// the list
myLList.InsertLList(data);
myLList.displayLList();
myLList.SearchLList(data);
myLList.RemoveItem(key);
myLList.freeLLmemory();
}
errors
: error C3861: 'freeLLMemory': identifier not found
: error C2511: 'bool LList::SearchLList(Node &,int)' : overloaded member function not found in 'LList'
: see declaration of 'LList'
: error C2660: 'LList::SearchLList' : function does not take 2 arguments
: error C2039: 'key' : is not a member of 'Node'
: see declaration of 'Node'
: error C2039: 'name' : is not a member of 'Node'
: see declaration of 'Node'
: error C2039: 'freeLLMemory' : is not a member of 'LList'
: see declaration of 'LList'
: error C2601: 'freeLLMemory' : local function definitions are illegal
.h(77): this line contains a '{' which has not yet been matched
: error C2761: 'void LList::displayLList(void)' : member function redeclaration not allowed
: error C2039: 'key' : is not a member of 'Node'
h(10) : see declaration of 'Node'
: error C2039: 'name' : is not a member of 'Node'
: error C2601: 'main' : local function definitions are illegal
h(77): this line contains a '{' which has not yet been matched
: fatal error C1075: end of file found before the left brace '{
The listed functions are either misstyped (like freeLLMemory) or have the wrong paramter (like SearchLList(Node &nodeOut,int key) <-> SearchLList(DataType data);)