Write a program that defines a template function named add(). Thisfunction takes
ID: 3608512 • Letter: W
Question
Write a program that defines a template function named add(). Thisfunction takes two arguments, add two variables and then return thesum.In main function, define two variables of type int, two variablesof type float and two objects of type ‘String’. Nowcall the add() function three times for these different datatypes.
Note: String is a user-defined data type and for this you have todefine a class named ‘String’. When template functionwill be called to add two objects of type String then it mustconcatenate two strings.
Your output should look like this:
Sample Output:
Enter two integer values to be added
Enter First value: 12
Enter Second value: 25
Enter two float values to be added
Enter First value: 13.5
Enter Second value: 14.2
Enter two Strings to be added
Enter First value: Virtual
Enter Second value: University
Addition of two variables of different data types
Sum of values of type int = 37
Sum of values of type float = 27.7
Sum of values of type String = VirtualUniversity
Explanation / Answer
x.x
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.