public static void Main(string[] args) { ptBac2 a = new ptBac2(-1, 2, -3); ptBac2 b = new ptBac2(4, -5, 6); Console.Write("Phuong trinh 1 co dang: "); a.xuat(); Console.Write("Phuong trinh 2 co dang: "); b.xuat(); ptBac2 tong = a + b; ptBac2 hieu = a - b; a--; b--; Console.Write("Phuong trinh 1 dao nguoc co dang: "); a.xuat(); Console.Write("Phuong trinh 2 dao nguoc co dang: "); b.xuat(); Console.Write("Phuong trinh tong co dang: "); tong.xuat(); Console.Write("Phuong trinh hieu co dang: "); hieu.xuat(); Console.ReadKey(); }
public static ptBac2 operator -(ptBac2 pt1, ptBac2 pt2) { ptBac2 ptTong = new ptBac2(); ptTong.a = pt1.a - pt2.a; ptTong.b = pt1.b - pt2.b; ptTong.c = pt1.c - pt2.c; return(ptTong); }
public static ptBac2 operator--(ptBac2 pt) { ptBac2 pt2 = new ptBac2(); pt2.a = -1 * pt.a; pt2.b = -1 * pt.b; pt2.c = -1 * pt.c; return(pt2); }