Unix_C++_SYS_Mini_Project
Implement Stack class that stacks “strings” as per the specification given below:
class StackFull {}; // used as exception-type
class StackEmpty {}; // used as exception-type
Class Stack
{
public:
Stack(int n); // creates an array of “n” strings (C++ string type)
void push(const string& s) throw(StackFull);
// has to push string “s” onto the stack.
// in case stack is full, should throw StackFull exception
void pop(string& s) throw(StackEmpty);
// has to pop string from stack and return it through argument “s”
// in case stack is empty, should throw StackEmpty exception
void top(string& s) throw(StackEmpty);
// has to return the topmost element of the stack through argument “s”
// in case stack is empty, should throw StackEmpty exception
bool isEmpty(); // should return true if the stack is empty; otherwise false
bool isFull); // should return true if the stack is empty; otherwise false
~Stack(); // should perform cleanup
private:
string *arystr;
int top;
int stacksize;
};
a) Implement different test cases to test the correctness of the Stack class implementation.
Call the test functions in main().
---X---