I think I would have to use the following code:
public static Point operator + (Point point1, Point point2)
{
return new Point(point1.X + point2.X, point1.Y + point 2.Y);
}
But I don't know why it doesn't go
I think I would have to use the following code:
public static Point operator + (Point point1, Point point2)
{
return new Point(point1.X + point2.X, point1.Y + point 2.Y);
}
Operator that adds two Points
tirupati_mullick
Ok I think the problem is that I wasn't defining the operator in the Point class.
Thanks,
DaGlow
What probelm do you get The following works fine - I copied & pasted your method into this class:
class
Point{
private int x;
private int y;
public int X
{
get { return x; }
set { x = value; }
}
public int Y
{
get { return y; }
set { y = value; }
}
public Point(int x, int y)
{
this.X = x;
this.Y = y;
} public static Point operator+(Point point1, Point point2)
{
return new Point(point1.X + point2.X, point1.Y + point2.Y);
}
}