#include<conio.h>
class unary
{
int a,b,c;
public:
void get(int a1,b1,c1)
{
a=a1;b=b1;c=c1;
}
void operator -()
{
a=-a;
b=-b;
c=-c;
}
void disp()
{
cout<<"Value of A is :"<<a<<endl;
cout<<"Value of B is :"<<b<<endl;
cout<<"Value of C is :"<<c<<endl;
}
};
int main()
{
int x,y,z;
clrscr();
cout<<"Unary Minus Operator"<<endl;
cout<<"------- -------- -----------"<<endl;
cout<<"Enter Three Numbers :"<<endl;
cin>>x;
cin>>y;
cin>>z;
unary ob;
ob.get(x,y,z);
cout<<"Before Operator Overloading"<<endl;
cout<<"-------- ----------- ---------------"<<endl;
ob.disp();
cout<<endl;
-ob;
cout<<"After Operator Overloading"<<endl;
cout<<"------ ----------- ---------------"<<endl;
ob.disp();
cout<<endl;
getch();
}
No comments:
Post a Comment