Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

o Objective The objective of this assignment is to provide hands onexperience of

ID: 3608359 • Letter: O

Question

o                   

Objective

The objective of this assignment is to provide hands onexperience of using

o                   Classes and objects

o                   Template Functions

Question :

Marks:10      

Write a program that defines a template function namedadd(). This function takes two arguments, add twovariables and then return the sum.

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 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 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

o                   

Objective

The objective of this assignment is to provide hands onexperience of using

o                   Classes and objects

o                   Template Functions

Question :

Marks:10      

Write a program that defines a template function namedadd(). This function takes two arguments, add twovariables and then return the sum.

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 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 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

#includeusing namespace std;class String{public:string str;String(string s){str=s;}void print(){couti2;cout