Question: Consider the definition of the following function template: template void funcExp(Type list[], int size) { Type x = list[0]; Type y = list[size - 1];
Consider the definition of the following function template:
template
void funcExp(Type list[], int size) {
Type x = list[0];
Type y = list[size - 1];
for (int j = 1; j < size; j++) {
if (x < list[j])
x = list[j];
if (y > list[size - 1 -j])
y = list[size - 1 -j];
}
cout << x << endl;
cout << y << endl;
}
Embed the above function template into a program with a main function.
Add the following data into the main function:
int list[10] = {5,3,2,10,4,19,45,13,61,11};
string strList[] = {"One", "Hello", "Four", "Three", "How", "Six"};
and call the function with the following function calls:
funcExp(list, 6);
funcExp(strList, 6);
Explain:
1. the meaning of template
2. the meaning of Type
3. the running result
What is the outcome of function call funcExp(list, 10) (Explain without running the program).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
