hi everyone..i really need help as fast as possible..i have 14 errors in the program..it is a linked list implementation for reversing a stack using recursion..
here is the code:
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include<cstdlib>
#include <fstream>
using std::ifstream;
using std::ofstream;
#include"ItemType.h"
using namespace std;
struct NodeType
{
ItemType info;
NodeType* next;
};
class stack
{
private:
NodeType* topPtr;
public:
stack();
void push(ItemType);
int pop();
bool isempty();
bool isfull();
void print();
void print_reverse(stack);
void reverse(node)
void push(ItemType);
};
stack::stack()
{
topPtr = NULL;
}
void stack::push(ItemType newItem)
{
NodeType* location;
location = new NodeType;
location->info = newItem;
location->next = topPtr;
topPtr = location;
}
int stack::pop()
{
NodeType* tempPtr;
tempPtr = topPtr;
topPtr = topPtr ->next;
delete tempPtr;
}
bool stack::isempty()
{
return (topPtr == NULL);
}
bool stack::isfull()
{
NodeType* location;
location = new NodeType;
if(location != NULL)
{
delete location;
return false;
}
else
return true;
}
void stack::print()
{
while(!isempty())
cout<<pop()<<endl;
}
void stack::print_reverse(stack st)
{
if (ptr! =(node*) NULL)
print_reverse(ptr->next)
print ptr->info;
}
void stack::reverse(node* ptr){
if (ptr! =(node*) NULL)
reverse(ptr->next)
Print ptr->info;
}
int main()
{
stack x;
int data;
ItemType item;
ifstream instream;
ofstream outstream;
instream.open("input.txt");
outstream.open("output.txt");
if(instream.fail()){
cout<<"Error opening file\n";
exit(1);
}
while ( !instream.eof() )
{
if (isfull())
break;
instream>> data;
item.Initialize(data);
int temp = item.getvalue();
push(temp);
print();
}
instream.close();
cout<<"--------\n";
print_reverse(MAX_ITEMS);
cin.get();
outstream.close();
return 0;
}
these are the errors that appear..plz help
error C2061: syntax error : identifier 'node'
error C2144: syntax error : 'void' should be preceded by ';'
error C2535: 'void stack::push(ItemType)' : member function already defined or declared
see declaration of 'stack::push'
error C2065: 'ptr' : undeclared identifier
error C2143: syntax error : missing ')' before '!'
error C2059: syntax error : '='
error C2059: syntax error : ')'
error C2065: 'node' : undeclared identifier
error C2065: 'ptr' : undeclared identifier
error C2448: 'stack::reverse' : function-style initializer appears to be a function definition
error C3861: 'isfull': identifier not found
error C3861: 'push': identifier not found
error C3861: 'print': identifier not found
error C3861: 'print_reverse': identifier not found
1>unsorted list - 14 error(s), 0 warning(s)