Write a program that defines atemplate function named add(). This function takes
ID: 3608438 • Letter: W
Question
Write a program that defines atemplate function named add(). This function takestwo arguments, add two variables and then return the sum.
In main function, define twovariables of type int, two variables of type float and two objectsof type ‘String’. Now call the add() function threetimes for these different data types.
Note: String is a user-defineddata type and for this you have to define a class named‘String’. When template function will be called to addtwo objects of type String then it must concatenate twostrings.
Your output should look likethis:
Sample Output:
Enter two integer values to beadded
Enter First value:12
Enter Second value:25
Enter two float values to beadded
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 ofdifferent 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
please rate - thanks you can find your answer at this post /computer-science-topic-5-455607-cpi0.aspx
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.