Running Argument: (C++) Step 1 :
IV. Running Argument: (C++)
Step 1: Write a program that reads in information for two runners in a race and swaps their information if necessary so that the runner with the faster time is stored in a variable called winner and the other is stored in a variable called loser. There are many ways to do this, of course, but to develop your understanding of templates, you should do this the following way:
Prompt the user to input the first runner's name, age, weight, and time. Store them in variables named winner_name, winner_age, winner_weight, and winner_time, which are a string, int, double, and Time, respectively (using Horstmann's Time class). Then do the same for the second runner, storing in other variables. Depending on the runners' times, you may need to swap these variables. Since four different types are involved, you are to write a template swap routine that performs the swap, then call it with each of the appropriate arguments.