/*------------------------------------------------------------------------- Driver program to test the Stack class. -------------------------------------------------------------------------*/ #include #include using namespace std; #include "DStackT.h" template void print(Stack st) { st.display(cout); } int main() { int cap; cout << "Enter stack capacity: "; cin >> cap; Stack intSt; // stack of ints Stack charSt; // stack of chars for (int i = 1; i <= 4; i++) intSt.push(100*i); cout << intSt << endl; for (char ch = 'A'; ch <= 'D'; ch++) charSt.push(ch); cout << charSt << endl; cout << "Contents of stack intSt (via print):\n"; print(intSt); cout << endl; Stack t; t = intSt; cout << "Contents of stack t after t = stInt (via print):\n"; print(t); cout << endl; cout << "Stack t empty? " << boolalpha << t.empty() << endl; cout << "Top value in t: " << t.top() << endl; while (!t.empty()) { cout << "Popping t: " << t.top() << endl; t.pop(); } cout << "Stack t empty? " << t.empty() << endl; cout << "Top value in t: " << t.top() << endl; cout << "Trying to pop t: " << endl; t.pop(); }