uniary overloading
#include <iostream>
using namespace std;class Point
{
int x, y;
public:
Point()
{
x = 5;
y = 7;
}
void operator ++(int)
{
x++;
y++;
}
void showPoint()
{
cout<<"Point - x: "<<x<<" y: "<<y<<endl;
}
};
int main()
{
Point p1;
p1++;
p1.showPoint();
return 0;
}
Comments
Post a Comment