Stack:#ifndef STACKTYPE_H_INCLUDED #define STACKTYPE_H_INCLUDED const int MAX_ITEMS = 5; class FullStack // Exception class thrown // by Push when stack is full. {}; class EmptyStack // Exception class thrown // by Pop and Top when stack is emtpy. {}; template class StackType { public: StackType(); bool IsFull(); bool IsEmpty(); void Push(ItemType); void Pop(); ItemType Top(); private: int top; ItemType items[MAX_ITEMS]; }; #endif // STACKTYPE_H_INCLUDED Queue:#ifndef QUETYPE_H_INCLUDED #define QUETYPE_H_INCLUDED template class QueType { public: QueType(); QueType(int); ~QueType(); void MakeEmpty(); bool IsEmpty(); bool IsFull(); void Enqueue(T); void Dequeue(T&); T Front(); private: int front; int rear; T *info; int maxQue; }; #endif // QUETYPE_H_INCLUDED
Stack:#ifndef STACKTYPE_H_INCLUDED
#define STACKTYPE_H_INCLUDED
const int MAX_ITEMS = 5;
class FullStack
// Exception class thrown
// by Push when stack is full.
{};
class EmptyStack
// Exception class thrown
// by Pop and Top when stack is emtpy.
{};
template <class ItemType>
class StackType
{
public:
StackType();
bool IsFull();
bool IsEmpty();
void Push(ItemType);
void Pop();
ItemType Top();
private:
int top;
ItemType items[MAX_ITEMS];
};
#endif // STACKTYPE_H_INCLUDED
Queue:#ifndef QUETYPE_H_INCLUDED
#define QUETYPE_H_INCLUDED
template<class T>
class QueType
{
public:
QueType();
QueType(int);
~QueType();
void MakeEmpty();
bool IsEmpty();
bool IsFull();
void Enqueue(T);
void Dequeue(T&);
T Front();
private:
int front;
int rear;
T *info;
int maxQue;
};
#endif // QUETYPE_H_INCLUDED


Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









