0

I have been given the task to Design,Develop,Test and Document an application on a stack class. The stack class's public interface should consist of methods to initialize a stack object, to check whether a stack is full or empty, to push integers onto the stack, to pop integers off a stack and to print a stack to the standard output without removing any element.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by NathanOliver
0

Well here's a starter for you :
Let the class be something like this ...

class stack{
int arr[50]; //To create a stack of size 50 
int top=-1; //Initial value for the variable holding the top position in the stack;
public:
int push(int x); //Function which takes x as the parameter and pushes it into the array after checking the limits by arr[++top]=x make this function return 1 on success and 0 on failure
int pop(); //Function which implements return arr[top--] make this function return the top value on success and 0 on failure.
void display(); //Make this function display contents of the stack in top to down manner
};

Once you successfully implement this convert it into a better stack by use of template functions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.