cube of an integer and float using operator oerloading in cpp
#include <iostream>
using namespace std;
int cube(int);
float cube(float);
int main()
{
int a,x;
float b,y;
cout<<"enter an intege";
cin>>a;
x=cube(a);
cout << "cube of integer: " << x << endl;
cout << "Enter a float number\n";
cin >>b;
y=cube(b);
cout << "cube of floats: " << y << endl;
return 0;
}
int cube(int x)
{
int m;
m=x*x*x;
return m;
}
float cube(float y)
{
float n;
n=y*y*y;
return n;
}

0 comments: