complex::operator-=

복소수 대상에서 빼고, 뺄 수 복잡할 수 같은 형식으로 추가 되어 복소수의 실수부와 허수부 부분 큽니다.

template<class Other>
   complex<Type>& operator-=(
      const complex<Other>& _ComplexNum
   );
complex<Type>& operator-=(
   const Type& _RealPart
);
complex<Type>& operator-=(
   const complex<Type>& _ComplexNum
);

매개 변수

  • _ComplexNum
    대상 복소수에서 뺄 수 복잡 한 수 있습니다.

  • _RealPart
    대상 복소수에서 뺄 수 실수.

반환 값

뺀 매개 변수로 지정 된 번호를 가진 복소수.

설명

데이터를 특정 형식으로 변환 하지 않고 간단한 산술 연산을 실행할 수 있도록 작업 오버 로드 됩니다.

예제

// complex_op_se.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>

int main( )
{
   using namespace std;
   double pi = 3.14159265359;

   // Example of the first member function
   // type complex<double> subtracted from type complex<double>
   complex <double> cl1 ( 3.0 , 4.0 );
   complex <double> cr1 ( 2.0 , -1.0 );
   cout << "The left-side complex number is cl1 = " << cl1 << endl;
   cout << "The right-side complex number is cr1 = " << cr1 << endl;

   complex <double> cs1 = cl1 - cr1;
   cout << "The difference between the two complex numbers is:"
        << "\n cs1 = cl1 - cr1 = " << cs1 << endl;

   // This is equivalent to the following operation
   cl1 -= cr1;
   cout << "Complex number cr1 subtracted from complex number cl1 is:"
        << "\n cl1 -= cr1 = " << cl1 << endl;

   double abscl1 = abs ( cl1 );
   double argcl1 = arg ( cl1 );
   cout << "The modulus of cl1 is: " << abscl1 << endl;
   cout << "The argument of cl1 is: "<< argcl1 << " radians, which is " 
        << argcl1 * 180 / pi << " degrees." << endl << endl; 

   // Example of the second member function
   // type double subtracted from type complex<double>
   complex <double> cl2 ( 2.0 , 4.0 );
   double cr2 = 5.0;
   cout << "The left-side complex number is cl2 = " << cl2 << endl;
   cout << "The right-side complex number is cr2 = " << cr2 << endl;

   complex <double> cs2 = cl2 - cr2;
   cout << "The difference between the two complex numbers is:"
        << "\n cs2 = cl2 - cr2 = " << cs2 << endl;

   // This is equivalent to the following operation
   cl2  -= cr2;
   cout << "Complex number cr2 subtracted from complex number cl2 is:"
        << "\n cl2 -= cr2 = " << cl2 << endl;

   double abscl2 = abs ( cl2 );
   double argcl2 = arg ( cl2 );
   cout << "The modulus of cl2 is: " << abscl2 << endl;
   cout << "The argument of cl2 is: "<< argcl2 << " radians, which is " 
        << argcl2 * 180 / pi << " degrees." << endl << endl;
}
  
  

요구 사항

헤더: <complex>

네임 스페이스: std

참고 항목

참조

complex Class