I have a stack.cpp defined as the below. My problem is I also have 2 separate classes infix.h and postfix.h and I want to have the stack accessible from both of them and not sure exactly where to implement them. I'm almost 99% sure it has to have to do something with where the stack objects are defined
If I put
Infix InEx;
Postfix PostEx;
TStack<double> Numbers;
TStack<char> Op;
in main I can't manipulate the stack in
the class. I need to somehow manipulate the Postfix object by passing it in with a convert function like the below.
Infix.Convert(PostEx);
template <class TItem> class TStack
{
private:
int Top;
TItem Data[64];
public:
TStack ();
void Push (TItem Item);
void Pop (TItem &Item);
};
template <class TItem>
inline TStack<TItem>::TStack ()
{
Top = -1;
}
template <class TItem>
inline void TStack<TItem>::Push (TItem Item)
{
if (Top < 64 - 1 )
{
Top++;
Data[Top] = Item;
}
}
template <class TItem>
inline void TStack<TItem>::Pop (TItem &Item)
{
if (Top != -1)
Top--;
}