I have a header class that was written for me that creates a stack that you can call different functions on. I am having trouble with how to use this code in another file. I would like to know how to create a stack in another file, like how to initialize a stack. Thanks in advance. Here is the code for the stack class:
#ifndef STACK_H_
#define STACK_H_
#include <iostream>
using namespace std;
class Stack
{
public:
Stack( ) : Top(-1), Size(0) { }
~Stack( ) { }
void Push (int X)
{ Top += 1; Size +=1; S[Top] = X;}
int Pop ()
{ Size -= 1; return S[Top--]; }
Stack & operator = (Stack const& x) // assignment operator
{ Top = x.Top;
Size = x.Size;
for (int i = 0; i < x.Size; i++)
S[i] = x.S[i];
return *this;
}
void Print()
{ int i;
for (i = 0; i < Size; i++)
cout << S[i] << " ";
}
int GetSize( ) const
{ return Size;}
int IsEmpty( ) const
{ if (Top < 0) return 1;
else return 0;}
private:
int S[100];
int Top;
int Size;
};
#endif