Question: Here is part of a short program: int main() { using namespace std; // list of double deduced from list contents auto q = average_list({15.4,

Here is part of a short program:
int main()
{
using namespace std;
// list of double deduced from list contents
auto q = average_list({15.4, 10.7, 9.0});
cout << q << endl;
// list of int deduced from list contents
cout << average_list({20, 30, 19, 17, 45, 38} ) << endl;
// forced list of double
auto ad = average_list({'A', 70, 65.33});
cout << ad << endl;
return 0;
}

Complete the program by supplying the average_list() function. It should be a template function, with the type parameter being used to specify the kind of initialized_list template to be used as the function parameter and also to give the function return type.

Step by Step Solution

3.39 Rating (174 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

template auto ave... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction Java Program Questions!