Write a C++ program to define two function templates for calculating the square and cube of give n numbers with different data types.
#include<conio.h>
#include<stdlib.h>
class
Calculator
{
private:
T
num1;
Calculator(T
n1)
{
num1
= n1;
}
{
cout
<< "Numbers are: " <<num1<<endl;
cout
<< "Square is: " <<square()<<endl;
cout
<< "Cube is: " <<cube()<<endl;
}
T
cube() { return num1*num1*num1; }
};
{
Calculator<int>
intCalc(2);
Calculator<float>
floatCalc(3.1);
intCalc.displayResult();
floatCalc.displayResult();
return
0;
}