because another guy is andivising me to do so..but now the program has changed upside down and still not working..it has an error
Quote:
1>c:\documents and settings\ahmed aburumman\desktop\unsorted list.cpp(44) : error C2065: 'st' : undeclared identifier
here is the code:
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;
class stack
{
private:
        static const int MAX_ITEMS=10;  
        int st[MAX_ITEMS];
        int top;
public:
	
	stack();
	void push(int);
	int pop();
	bool isempty();
	bool isfull();
	void print();
	void print_reverse(int);
};

stack::stack(){top=-1;}
void stack::push(int v){st[++top]=v;}
int stack::pop(){return st[top--];}
bool stack::isempty(){return (top==-1);}
bool stack::isfull(){return top==MAX_ITEMS-1;}
void stack::print()
{
while(!isempty())
cout<<pop()<<endl;
}

void print_reverse(int i)
{
	
   if(i<MAX_ITEMS && i >= 0)
   {
         cout<<st[i]<<endl;
         print_reverse(--i);
   }
}


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 (x.isfull())
			break;
		instream>> data;	
		item.Initialize(data);
		 int temp = item.getvalue();
		x.push(temp); 
		x.print();
		
	}
	instream.close();

	cout<<"--------\n";
	x.print_reverse(MAX_ITEMS-1);
	cin.get();
	outstream.close();
    return 0;
}

Last edited by elsa87; 25Nov2008 at 09:38..