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)

You can start a new thread everytime someone doesn't give you the answer you like, but you could also try solving some of the errors yourself.
I bet you didn't change anything I suggested in the "ItemType.h" file right?
In your other thread I also mentioned that you had missing semicolons and brackets-misallignment. But in this code you still didn't fix those problems. See:

void print_reverse(stack);
void reverse(node)   <-- Where's the semicolon?
void push(ItemType);

Now change these things and try to find some more using your own eyes and brain. The compiler is telling you exactly where the problems are, so change them.

This article may also be useful for you.

hi..actually i did try to solve them..htey were 39 and u can see the changes now..i'm trying really hard and i want to solve it..
what's wrong with calling this function?
print_reverse(MAX_ITEMS);??

what's wrong with calling this function?
print_reverse(MAX_ITEMS);??

print_reverse() is a member function from the class 'stack'. You have declared this in your program : stack x; , so you should call it's members as: x.print_reverse(MAX_ITEMS);

i did that..but still have 10 errors

error C2061: syntax error : identifier 'node'
error C2535: 'void stack::push(ItemType)' : member function already defined or declared
see declaration of 'stack::push'
error C2065: 'node' : undeclared identifier
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 C2664: 'stack::push' : cannot convert parameter 1 from 'int' to 'ItemType'
error C2664: 'stack::print_reverse' : cannot convert parameter 1 from 'const int' to 'stack'

i did that..but still have 10 errors

Why don't you just READ the errormessages?
Let's take the first one:

error C2061: syntax error : identifier 'node'

So what does this tell you? You're probably using the identifier 'node' somewhere and the compiler doesn't understand where that name came from.
So where did you declare 'node' ? Answer: nowhere.

isn't this a declaration for the node?
void stack::reverse(node* ptr)

1. void stack::reverse(node* ptr) // node ???
    //--
    void stack::reverse(NodeType* ptr) 
2. class stack
   {
        private:
             NodeType* topPtr;
        public:
	
	     stack();
	     void push(ItemType);         // see this
	     int pop();
	     bool isempty();
	     bool isfull();
	     void print();
	     void print_reverse(stack);
	     void reverse(node)
	     void push(ItemType);              // and this
    };
3. node,??? maybe NodeType
4. push(...), there is no global function named push...
    maybe, x.push(...).
5. isfull(...), ??? maybe x.isfull(...).
6. print_reverse(...), ???? maybe x.print_reverse(...).

isn't this a declaration for the node?
void stack::reverse(node* ptr)

If you had implemented "node" somewhere, then yes. But you didn't.
If you do not grasp these simple concepts such as understanding compiler-errors, then making a linked list or stack or whatever is far out of your league...

im not sure what ur saying..r u telling me that in the public i should write push, print_reverse, ans is full like that:
void x.push(ItemType);??
and by the way sorry i relalized i've declared the push twice in the public

it is indeed out of my league lol..im not at all good in programming.. but im trying my best..i have to do this assignment..i've already done 2 and im sure i can do this one..i will just need patience and hard work..right?
so i should declare node as what? an integer? itemType?or should i change it to NodeType?

see main body...

push(...); //see this, there is no global function named push. it is a class member function, what's wrong with you..
x.push(...); // this, this, this...????

aha u mean in the main..i corrected this mistake for the push and the others..im now in the other mistakes..

node...change it to NodeType..
then give me some error message

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.