9 class Underflow
{ }; // exception
10 class Overflow
{ }; // exception
11 class Bad_size
{ }; // exception
13 Stack(int s
); // constructor
14 ~Stack(); // destructor
27 v
= new char[s
]; // allocate elements on the free store (heap)
35 void Stack::push(char c
)
50 Stack
s_var1(10); // global stack with 10 elements
54 Stack
s_var2(5); // local stack with 5 elements
55 Stack
*s_ptr
= new Stack(20); // pointer to allocated stack
61 std::cout
<< s_ptr
->pop();
65 std::cout
<< s_ptr
->pop();
67 catch (Stack::Underflow
) {
68 std::cerr
<< "ERROR: No elements in the stack!\n";