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.

Recommended Answers

All 3 Replies

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.

hey Shawn what exactly is your signature? sorry for going off topic.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.