Lab 16A: Function Templates

  < Previous  Next >

Assignment:

Submit a copy of lab16A.cpp that has:
  1. A templated add() function that takes two arguments, each of which can be a separate type, and returns the result of calling the + operator on the arguments. The return type should be the type of the first argument.
  2. A call to add(), passing it answer and pi
  3. A call to add(), passing it str1 and str2
No other changes should be necessary.

Finally, when your code is executed, the output must match what's in lab16A-answerKey.txt exactly:
45
Yeah, my templated function works!

Submission

Submit your source code using the handin program. For handin, for this lab, type the following in a terminal window exactly as it appears:
handin  lab16A  lab16A.cpp
To verify your submission, type the following in a terminal window:
handin  lab16A