Here is part of a short program: int main() { using namespace std; // list of double

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, 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

C++ Primer Plus

ISBN: 9780321776402

6th Edition

Authors: Stephen Prata

Question Posted: