Program of UNARY OPERATOR OVERLOADING using member function

/* Program of UNARY OPERATOR OVERLOADING using member function */

#include
#include
class A
{
int a,b;
public:
void getdata(int r,int s) //parameterised constructor
{
a=r;
b=s;
}
void display()
{
cout<<"\na="<>q>>w;
A a1;
A1.getdata(q,w);
a1.display();
+a1;
Cout<<”\n\nAfter operator overloading :”; a1.display(); getch(); return 0; }
OUTPUT :

Enter 2 numbers
3 4
a=3
b=4

After operator overloading
a=-3
b=-4







Leave a Reply

Your email address will not be published. Required fields are marked *