:\Documents and Settings\Andrew\Desktop\Important stuff\ACS 279\Program1\stackLLClient.cpp(36) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a
conversion to a type acceptable to the predefined operator
C:\Documents and Settings\Andrew\Desktop\Important stuff\ACS 279\Program1\stackLLClient.cpp(36) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a
conversion to a type acceptable to the predefined operator
C:\Documents and Settings\Andrew\Desktop\Important stuff\ACS 279\Program1\stackLLClient.cpp(40) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a
conversion to a type acceptable to the predefined operator
C:\Documents and Settings\Andrew\Desktop\Important stuff\ACS 279\Program1\stackLLClient.cpp(40) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a
conversion to a type acceptable to the predefined operator
Error executing cl.exe.
stackLLClient.obj - 4 error(s), 0 warning(s)
Code:
#include<iostream.h>
#include"stackLL.h"
//constructor
character::character()
{
head=NULL;
cur=NULL;
pre=NULL;
}
//destructor
character::~character()
{
node *ptr;
while(head!=NULL) //delete all the numbers
{
ptr=head->next;
delete head;
head=ptr;
}
}
int character::push(int num, int success)
{
if(head==NULL)
{
head=new node;
head->num=num;
head->next=NULL;
success=1;
}
else
{
cur=head;
head=NULL;
head=new node;
head->num=num;
head->next=cur;
success=1;
}
return success;
}
//****remove at the head, this is stack, push at the head remove at the head.
int character::pop(int num, int success)
{
node *temp; //make a temp pointer
if(head!=NULL) //if the list is not empty
{
temp=head->next; //temp equal to head ->next
delete head; //delete head, remove the first data of the list
head=temp; //now the second data of the list become the first data of the list
return success=1; //return success
}
else
return success=0; //if the list empty return fail
return success;
}
//this function will print from the beginning of the list to the end of the list
void character::print()
{
//if the list was empty print out an error message
if(head==NULL)
{
cout << "There isn't any number" << endl;
return;
}
//else while not the end of the list, print out the number and go to the next one
else
{
cur=head;
while(cur!=NULL)
{
cout << "number: " << cur->num << endl;
cur=cur->next;
}
}
}
//the search function was search from the beginning of the head to the end of the
//head.
int character::search(int num, int success)
{
if(head==NULL) //if there isn't any data return 0
{
success=0;
return 0;
}
if(head->num == num) //if delete the first node
{
cout << num << " was found" << endl;
success=1;
return 1;
}
else //else delete any node other than the first node
{
cur=head;
cur=cur->next;
while(cur!=NULL) //search all the to the end of the list
{
if(cur->num ==num)
{
cout << num << " was found" << endl;
success=1;
return 1;
}
pre=cur;
cur=cur->next;
success=0;
}// while
} //else
return success;
}