연산자 메서드 operator +(), operator-() , 연산자 오버로딩?
연산자 메서드를 부르려면 해당 연산자를 사용하며, 연산자를 사용하면 코드가 훨씬 직관적이기 때문에 이해하기 쉬워진다 using System; class Point { public int x; public int y; public Point( int x, int y ) { this.x = x; this.y = y; } public override string ToString() { // (x,y) 값 return String.Format("({0},{1})", x, y ); } // + 연산자 메서드 public static Point operator +(Point pt1, Point pt2) { return (new Point(pt1.x + pt2.x, pt1.y + pt2.y)); } // - 연산자 ..
더보기