Program to demonstrate the Stack class
#include <iostream>
#include <vector>
using namespace std;
template<class T>
class Stack
{
public:
Stack();
bool empty() const;
T top() const;
T pop();
void push(T element);
void Output(T element);
private:
vector <T> pool;
};
//constructor
template<class T>
Stack<T>::Stack()
{
pool.reserve(10);
}
//function to output the values in the stack
template<class T>
void Stack<T>::Output(T element)
{
}
int main()
{
Stack<double> dStack;
Stack<string> sStack;
cout << "Pushing 3.4, 5.5, 2.2, 6.7 -> on to dStack" << endl;
dStack.push(3.4);
dStack.push(5.5);
dStack.push(2.2);
dStack.push(6.7);
cout << endl;
cout << "Pushing Sawubona, Molo, Lotjha, Dumela, Hi, Hallo" << endl;
cout << "Ndi Masiari, Avuxeni -> on to sStack" << endl;
sStack.push("Sawubona");
sStack.push("Molo");
sStack.push("Lotjha");
sStack.push("Dumela");
sStack.push("Hi");
sStack.push("Hallo");
sStack.push("Ndi Masiari");
sStack.push("Avuxeni");
cout << endl << "dStack:" << endl;
Output(dStack);
cout << endl << "sStack:" << endl;
Output(sStack);
return 0;
}