The objective of this assignment isto provide hands on experience of using o Cla
ID: 3608535 • Letter: T
Question
The objective of this assignment isto provide hands on experience of using
o Classes and objects
o Template Functions
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
Explanation / Answer
x.x
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.