Section 23.16 Exercises
Checkpoint 23.16.2.
Write a templated function
sumList that will take in a vector of the template type. It should sum up all the elements using + then return the total.
Checkpoint 23.16.3.
Write a templated function
countMatches that will take in a vector of the template type and a value of the same type. It should return the number of elements in the vector that match the given value.
Checkpoint 23.16.4.
Make a templated struct
ItemCounter. An item counter should store item, a value of the templated type, and an int count, representing the number of that item. For instance, an ItemCounter<string> could store the string "apple" and the number 3.
Checkpoint 23.16.5.
Hint.
You built the logic in CheckpointΒ 23.13.1.
You have attempted of activities on this page.
