1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: // Listing C3-2
5: PlainBox<string> findBox(PlainBox<string> boxes[], int size, string target)
6: {
7: int index = 0;
8: bool found = false;
9: while (!found && (index < size))
10: {
11: if (target == boxes[index].getItem())
12: found = true;
13: else
14: index++;
15: } // end while
16:
17: assert(found); // Verify that there is a box to return
18: return boxes[index];
19: } // end findBox