Exercise 4.1

Create a Stack.h and a Stack.suffix, where suffix is whatever convention your compiler or project follows. Write a main() function to exercise the full public interface, and compile and execute it. Both the program text file and main() must include Stack.h:

					#include "Stack.h" 

The header file for our Stack class contains the necessary header file inclusions and the actual class declaration:

 #include <string> #include <vector> using namespace std; class Stack { public: bool push( const string& ); bool pop ( string &elem ); bool peek( string &elem ); bool empty() const { return _stack.empty(); } bool full() const { return _stack.size() == _stack.max_size(); } int size() const { return _stack.size(); } private: vector<string> _stack; ...

Get Essential C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.