public static TamThucBacHai operator -(TamThucBacHai f1, TamThucBacHai f2) { TamThucBacHai temp = new TamThucBacHai { a = f1.a - f2.a, b = f1.b - f2.b, c = f1.c - f2.c, }; return(temp); }
public static TamThucBacHai operator -(TamThucBacHai f) { TamThucBacHai temp = new TamThucBacHai { a = -f.a, b = -f.b, c = -f.c, }; return(temp); }
static void Main(string[] args) { TamThucBacHai f1 = new TamThucBacHai(1, -3, 2); TamThucBacHai f2 = new TamThucBacHai(142, -245, 100); f1 = -f1; f2 = -f2; Console.Write("tam thuc 1 :"); f1.Fx(); Console.Write("tam thuc 2 :"); f2.Fx(); TamThucBacHai tong = f1 + f2; TamThucBacHai Hieu = f1 - f2; Console.Write("Tong = "); tong.Fx(); Console.Write("Hieu = "); Hieu.Fx(); }