// File: HLtest2.cpp // #include #include "HList.h" #include "IntNode.h" #include "DoubleNode.h" #include "StringNode.h" using namespace std ; int main() { HList L1, L2; L1.push_front(new IntNode(9)) ; L1.push_front(new StringNode("World")) ; L1.push_front(new IntNode(8)) ; L1.push_front(new IntNode(7)) ; L1.push_front(new StringNode("Hello")) ; L1.push_front(new IntNode(6)) ; L1.push_front(new DoubleNode(3.14157926)) ; L1.push_front(new DoubleNode(2.78)) ; L2 = L1 ; cout << "L1 = " << L1 << endl ; cout << "L2 = " << L2 << endl ; HNode *ptr ; ptr = L1.find(StringNode("Hello")) ; StringNode *sptr; sptr = dynamic_cast(ptr) ; if (sptr == 0) cout << "Dynamic cast failed!!\n" ; sptr->set("Goodbye") ; cout << "L1 = " << L1 << endl ; cout << "L2 = " << L2 << endl ; }