//Program - 3 -overload Unary operator ~ (bitwise one's complement) using friend function
#include <iostream.h>
#include <conio.h>
class Test
{
int a, b;
public :
Test()
{
cout << " Enter Value a = ";
cin >> a;
cout << " Enter value b = ";
cin >> b;
}
void show()
{
cout << endl << "A = " << a;
cout << endl << "B = " << b;
}
friend void operator~(Test &);
};
void operator~(Test &ref)
{
ref.a = ~ref.a;
ref.b = ~ref.b;
}
void main()
{
clrscr();
Test obj;
obj.show();
~obj;
obj.show();
getch();
}
Comments
Post a Comment