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

Instructions Please read the followinginstructions carefully before submitting a

ID: 3608360 • Letter: I

Question

Instructions

Please read the followinginstructions carefully before submitting assignment:

It should be clear that yourassignment will not get any credit if:

o                   The assignment issubmitted after due date.

o                   The submittedassignment does not open or file corrupt.

o                   The assignment iscopied.

Note: You have to uploadonly .cppfile .Assignment in any other format (extension) will not beaccepted.

Objective

The objective of this assignment isto provide hands on experience of using

o                   Classes and objects

o                   Template Functions

Question :

Marks:10      

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 isa user-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 likethis:

SampleOutput:

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

Instructions

Please read the followinginstructions carefully before submitting assignment:

It should be clear that yourassignment will not get any credit if:

o                   The assignment issubmitted after due date.

o                   The submittedassignment does not open or file corrupt.

o                   The assignment iscopied.

Note: You have to uploadonly .cppfile .Assignment in any other format (extension) will not beaccepted.

Objective

The objective of this assignment isto provide hands on experience of using

o                   Classes and objects

o                   Template Functions

Question :

Marks:10      

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 isa user-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 likethis:

SampleOutput:

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

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