Exercise 2: Swapping Values
Generalize the function for swapping two values using templates.
We'll cover the following...
We'll cover the following...
Problem statement
In the code widget below, two functions named swap_values are declared—one for swapping int values and the other for double values.
Define a template class type function index_of_smallest that generalizes the function such that it finds the minimum value index for both int and double type array input values. This function takes two values passed by reference and swaps them.
Your function should swap the two int values and the two double values.
Note: Remove both the
intanddoubletypeindex_of_smallestfunctions and then write the code for the template class typeswap_valuesfunction there.