1: // Created by Frank M. Carrano and Tim Henry. 2: // Copyright (c) 2013 __Pearson Education__. All rights reserved. 4: // Section C2.4 6: #include <iostream> 7: #include <string> 8: #include "PlainBox.h" 9: #include "MagicBox.h" 11: using namespace std; 13: void placeInBox(PlainBox<string>* theBox, string theItem) 14: { 15: theBox->setItem(theItem); 16: } // end placeInBox 18: int main() 19: { 20: string specialItem = "Riches beyond compare!"; 21: string otherItem = "Hammer"; 22: 23: PlainBox<string>* myPlainBoxPtr = new PlainBox<string>(); 24: placeInBox(myPlainBoxPtr, specialItem); 25: cout << myPlainBoxPtr->getItem() << endl; 26: 27: MagicBox<string>* myMagicBoxPtr = new MagicBox<string>(); 28: placeInBox(myMagicBoxPtr, otherItem); 29: placeInBox(myMagicBoxPtr, specialItem); 30: 31: cout << myMagicBoxPtr->getItem() << endl; 32: 33: delete myPlainBoxPtr; 34: myPlainBoxPtr = nullptr; 35: delete myMagicBoxPtr; 36: myMagicBoxPtr = nullptr; 37: 38: return 0; 39: } // end main 41: /* 43: Riches beyond compare! 44: Hammer 46: */