// Created by Frank M. Carrano and Tim Henry. // Copyright (c) 2013 __Pearson Education__. All rights reserved. // Section C2.2 #include #include #include "PlainBox.h" #include "MagicBox.h" using namespace std; void placeInBox(PlainBox& theBox, string theItem) { theBox.setItem(theItem); } // end placeInBox int main() { string specialItem = "Riches beyond compare!"; string otherItem = "Hammer"; PlainBox myPlainBox; placeInBox(myPlainBox, specialItem); MagicBox myMagicBox; placeInBox(myMagicBox, otherItem); placeInBox(myMagicBox, specialItem); // specialItem is stored! cout << myMagicBox.getItem() << endl; // "Riches beyond compare!" PlainBox mySpecialBox = MagicBox(); mySpecialBox.setItem(otherItem); mySpecialBox.setItem(specialItem); // specialItem is stored! cout << mySpecialBox.getItem() << endl; // "Riches beyond compare!" return 0; } // end main /* Riches beyond compare! Riches beyond compare! */