This is a sample C++ Program on Operator Overloading. Using Operator Overloading, this program will find Cube of a number.
#include <iostream.h>
#include <conio.h>
class Calc
{
public:
int operator ( ) (int num)
{
int cb = num * num * num;
return (cb);
}
};
int main ( )
{
clrscr ( );
Calc cube;
int a, res;
cout<<"Enter A Number: ";
cin>>a;
res = cube (a);
cout<<"Cube Of " << a << " Is = " << res ;
getch ( );
return 0;
}
OUTPUT:
Enter A Number: 6
Cube Of 6 Is = 216
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com