Exercise 1: Finding Max in an Array
Let's generalize the function of finding a max element in an array by using templates.
We'll cover the following
Problem Statement
In this exercise, you need to define a Template Class type function array_max
that will generalize the function such that it finds the maximum value for both int
and double
type array input values. This function takes the array and the number of elements in the array as parameters.
Note: Remove both the
int
anddouble
typeindex_of_smallest
functions and then write the code for the Template Class typeindex_of_smallest
function there.
Sample input
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy