C++
Part 1: Developing And Testing A Stack Template
Write a template, Stack.h, to implement a LIFOstack. Here is the specification for its publicinterface:
class Stack{ ... Stack( ); // may have a defaulted parameter Stack(const Stack&); // copy constructor ~Stack(); Stack& operator=(const Stack&); void push(const V&); const V& peek( ); void pop( ); int size( ) const; bool empty( ) const; void clear( );};
If you use dynamic memory (and you surely will!) be sure toinclude the three memory management functions as public members,too. You may implement your Stack as arrayed or as linked --your choice.
Fully test your template in a test driver CPP namedStack.TestDriver.cpp, remembering to includeall the tests we've learned about in this class. Then usethe H file in the following application: