Write a program to overload unary (++) operator and unary
(--) operator.
#include <iostream>
using namespace std;
class classA {
public:
int x, y;
classA(int a, int b)
{
x = a;
y = b;
}
void operator+()
{
x++;
y--;
cout << "\nx & y (Increment): " << x << ", " << y;
}
};
int main()
{
classA a1(5, 6);
+a1;
return 0;
}
Comments
Leave a comment