1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: // Listing C3-3 5: PlainBox<std::string> findBox(PlainBox<std::string> boxes[], int size, 6: std::string target) throw(std::logic_error) 7: { 8: int index = 0; 9: bool found = false; 10: while (!found && (index < size)) 11: { 12: found = (target == boxes[index].getItem()); 13: if (!found) 14: index++; // Look at next entry 15: } // end while 16: 17: if (!found) 18: throw std::logic_error("Target not found in a box!"); 19: return boxes[index]; 20: } // end findBox