#include <iostream>
using namespace std;
class Unary
{
int a, b, c;
public:
Unary()
{
a = b = c = 0;
}
Unary(int i, int j, int k)
{
a = i;
b = j;
c = k;
}
friend Unary operator ++ (Unary & obj);
void Display();
};
Unary operator ++(Unary & obj)
{
++obj.a;
++obj.b;
++obj.c;
return obj;
}
void Unary::Display()
{
cout << a << ", ";
cout << b << ", ";
cout << c << "\n";
}
int main()
{
Unary a (12, 22, 33);
a.Display();
++a;
a.Display();
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
12, 22, 33
13, 23, 34
13, 23, 34