Create a template function for the class


Discussion:

Q: Using the below code all numbers class do the following:

- Create a template function for the class called Add15() that adds 15 to each of the two numbers and display the result

- Create a template function for the class called multiplybypoints5() that multiples 0.5 to each numbers in the parameter list and display result

-Create a template function greater() that adds the two numbers in the parameter list and divides the sum by the greater or the two numbers and display the resultinclude #

using namespace std;

void main()

{
allnumbers intnumbers;
allnumbers floatnumbers;

cout<<"using template class for integers....\n";
intnumbers.setvalues(53,91);
cout<<"\n the sum of 53 and 91 is ";
cout<cout<<"\n\n the difference between 53 and 91";
cout<<"is "<cout<<"\n\n the product of 53 and 91 is ";
cout<< intnumbers.multiply();
cout<<"\n\n 53 divided by 91 is ";
cout<< intnumbers.divide()<

cout<<"\n\n\n using template class for floating ";
cout<<"point numbers....\n";
floatnumbers.setvalues(53.4,91.6);
cout<<"\n the sum of 53.4 and 91.6 is ";
cout<cout<<"\n\n the difference between 53.4 and 91.6 is ";
cout<<"is"<cout<<\n\n the product of 53.4 and 91.6 is ";
cout<cout<<"\n\n 53.4 divided by 91.6 is ";
cout<< floatnumbers.divide()<

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create a template function for the class
Reference No:- TGS01937536

Now Priced at $25 (50% Discount)

Recommended (94%)

Rated (4.6/5)