source file name: optor3.cpp
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class Gamma
{
int x,y,z;
public:
void getdata(int a, int b,int c)
{
x=a;
y=b;
z=c;
}
void show()
{
cout<<" "<<x <<" "<<y <<" "<<z<<endl;
}
void operator*()
{
x=x*x;
y=y*y;
z=z*z;
}
};
void main()
{
clrscr();
cout<<"Operator overloading program: ";
Gamma G;
G.getdata(10,25,30);
cout<< "\n G= ";
G.show();
*G;
cout<<"\n after applying operator(*) function square values ";
cout<< "\n G= ";
G.show();
getch();
}
output:
Operator overloading program:
G= 10 25 30
after applying operator(*) function square values
G= 100 625 900
0 Comments
Post a Comment