Unity
[키워드] operator
JiHxxn
2024. 3. 17. 11:07
📜 information
- Operator(연산자)는 오버로딩(재정의) 하여 기능을 수정할 수 있다.
public struct Coord
{
public int x;
public int y;
public Coord(int _x, int _y)
{
x = _x;
y = _y;
}
public static bool operator ==(Coord c1, Coord c2)
{
return c1.x == c2.x && c1.y == c2.y;
}
public static bool operator !=(Coord c1, Coord c2)
{
return !(c1 == c2);
}
}
📖 참고 문서
C#/.NET 연산자 오버로딩(operator)
C++과 마찬가지로 C#/.NET에도 연산자 오버로딩을 지원한다. 연산자 오버로딩은 해당 언어 자체에서 제공하고 있는 연산자에 대하여 그 의미를 다시 부여하는 것을 말한다. 즉 +나 -, * 등과 같은 연
hijuworld.tistory.com