CJCoding With Joseph
15free / daySign inCreate account

Describe and Add Three Different Types

Write two function templates that each take THREE type parameters A, B and C:

- void describeThree(A a, B b, C c): prints the three values separated by , (comma and space) followed by a newline - auto sumThree(A a, B b, C c): returns a + b + c, letting auto pick the result type

Each type parameter is deduced from its own argument, so all three may differ. The tests call describeThree(1, 2.5, 'z') and describeThree(std::string("id"), 7, true) (a bool prints as 1), then print sumThree(1, 2, 3), sumThree(1, 2.5, 3) and sumThree(0.25, 1, 0.5), each result on its own line.

Do NOT write a main function.

Expected Output:

1, 2.5, z
id, 7, 1
6
6.5
1.75

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Templates
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.