// File: HStest1.cpp // // Testing a heterogeneous stack #include #include "HStack.h" #include "IntNode.h" #include "StringNode.h" #include "DoubleNode.h" using namespace std ; int main() { HStack S ; S.push(new IntNode(1)) ; S.push(new StringNode("one")) ; S.push(new DoubleNode(1.5)) ; S.push(new IntNode(2)) ; S.push(new StringNode("two")) ; S.push(new DoubleNode(2.5)) ; S.push(new IntNode(3)) ; S.push(new StringNode("three")) ; S.push(new DoubleNode(3.5)) ; S.push(new IntNode(4)) ; S.push(new StringNode("four")) ; S.push(new DoubleNode(4.5)) ; S.push(new IntNode(5)) ; S.push(new StringNode("five")) ; S.push(new DoubleNode(5.5)) ; cout << "Stack S: " << S << "\n" ; cout << " size = " << S.size() << "\n" ; S.pop() ; S.pop() ; S.pop() ; cout << "Top of the stack: " ; S.top()->print() ; cout << "\n" ; cout << "Stack S: " << S << "\n" ; cout << " size = " << S.size() << "\n" ; }