Question: Using template feature of C++, program a class Calculator with two data members of the user specified data type. The class should have a constructor

Using template feature of C++, program a class ‘Calculator’ with two data members of the user specified data type. The class should have a constructor to initialize these data members and the following functions. (Both function definitions are to be provided outside the class) .

a. A function to add the two data members

b. A function to multiply the data members

From your main program create objects of calculator for integer and float data members, call these functions and display the results.

Step by Step Solution

3.40 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution Code and output include include include using namespace std template class Calculator T x ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!