< Previous | Contents | Next >
After creating inventory, a vector of items, I display the first item through a returned reference.
cout << refToElement(inventory, 0) << "\n\n";
The preceding code calls refToElement(), which returns a reference to the element at position 0 of inventory and then sends that reference to cout. As a result, sword is displayed.
202 Chapter 6 n References: Tic-Tac-Toe