Описать класс для работы с комплексными числами. Определить методы для сложения, умножения чисел- C++(Си)

class TComlex
{
 public:
  double Re;
  double Im;
  TComplex ()
  {
  }
  TComplex (double Re, double Im)
  {
   this->Re=Re;
   this->Im=Im;
  }
  TComplex (TComlex Complex)
  {
   this->Re=Complex.Re;
   this->Im=Complex.Im;
  }
  ~TComplex ()
  {
  }
  TComplex operator + (TComlex y)
  {
   TComplex Result;
   Result.Re=Re+y.Re;
   Result.Im=Im+y.Im;
   return Result;
  }
  TComplex operator - (TComlex y)
  {
   TComplex Result;
   Result.Re=Re-y.Re;
   Result.Im=Im-y.Im;
   return Result;
  }
  TComplex operator * (TComlex y)
  {
   TComplex Result;
   Result.Re=Re*y.Re-Im*y.Im;
   Result.Im=Re*y.Im+Im*y.Re;
   return Result;
  }
  TComplex operator * (double y)
  {
   return (*this)*TComlex(y,0);
  }
};

Leave a Comment