class Point code example
Example: point class
{
private:
int x, y;
public:
Point(int i = 0, int j = 0)
{
x = i;
y = j;
}
void print()
{
cout << endl
<< " x = " << x << ", y = " << y;
}
Point operator+(Point p1)
{
Point p2;
p2.x = x + p1.x;
p2.y = y + p1.y;
return p2;
};
Point operator*(int m)
{
Point p1;
p1.x = m * x;
p1.y = m * y;
return p1;
};
friend Point operator*(int m, Point p)
{
Point p1;
p1.x = m * p.x;
p1.y = m * p.y;
return p1;
};
};