static void Main(string[] args) { Kilogram k1 = new Kilogram(10); Kilogram k2 = new Kilogram(20); Kilogram k3 = k1 + k2; Console.WriteLine(k3); Gram g4 = new Gram(1000); Kilogram g5 = (Kilogram)g4; //명시적 형변환 Console.WriteLine(g5); }
static void Main(string[] args) { Kilogram kilo = new Kilogram(5); Kilogram gram = new Kilogram(10); Kilogram kilogram = kilo + gram; //연산자 오버로딩 사용 }