class Stack

Following is the definition of a class called Stack. Create a header file with name Stack.h and copy the following code into the file. Complete the header file by providing the definitions of all the member functions (methods) listed in the public section

using namespace std;

template<clsss ItemType>
class Stack
bool isEmpty();
bool push(ItemType a);
bool pop();
ItemType peek();
bool display();
ItemType elements[100];
int top;//index of the item that is on the top of the stack
int getCurrentTop()
return top;
void setCurrentTop(int s)


Descriptions of member functions:

Stack() is a default constructor that initialize the data member top to 0.

bool isEmpty() checks if the stack is empty (top==0). If it is, return true, otherwise return false.

bool push(T a) adds a new item to the top of the stack
bool pop() remove the item from the top of the stack.
T peek() returns the item that is on the top of the stack.
bool display() displays all the data items currently on the stack.
So...what part of this do you not understand?
Topic archived. No new replies allowed.