In main function, define two variables of type int, twovariables of type float a
ID: 3608362 • Letter: I
Question
In main function, define two variables of type int, twovariables of type float and two objects of type‘String’. Now call the add() function three times forthese different data types.
Note: String is auser-defined data type and for this you have to define a classnamed ‘String’. When template function will be calledto add two objects of type String then it must concatenate twostrings.
Your output should look like this:
SampleOutput:
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
#includeusing namespace std;class String{public:string str;String(string s){str=s;}void print(){couti2;coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.