다음을 통해 공유


operator- (<complex>)

빼고 두 복소수, 하나 또는 둘 다 있습니다 실수부와 허수부 파트 형식의 하위 집합에 속합니다.

template<class Type>
   complex<Type> operator-(
      const complex<Type>& _Left,
      const complex<Type>& _Right
   );
template<class Type>
   complex<Type> operator-(
      const complex<Type>& _Left,
      const Type& _Right
   );
template<class Type>
   complex<Type> operator-(
      const Type& _Left,
      const complex<Type>& _Right
   );
template<class Type>
   complex<Type> operator-(
      const complex<Type>& _Left
   );

매개 변수

  • _Left
    복소수-작업으로 뺄 수 있는 매개 변수의 형식이 숫자 또는 두 개의 복소수를 첫 번째.

  • _Right
    복소수-작업으로 뺄 수 있는 매개 변수의 형식이 숫자 또는 두 번째.

반환 값

결과에서 빼기 복소수 _Right 에서 _Left, 두 숫자 값으로 매개 변수 입력 지정 됩니다.

설명

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

단항 연산자 복잡 한 숫자의 부호를 변경 및 해당 실제 일부 음수 숫자 입력의 실제 부분입니다 가진 가상의 일부인 음의 허수 부분의 숫자 입력 값을 반환 합니다.

예제

// complex_op_sub.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> minus type complex<double>
   complex <double> cl1 ( 3.0 , 4.0 );
   complex <double> cr1 ( 2.0 , 5.0 );
   complex <double> cs1 = cl1 - cr1;

   cout << "The left-side complex number is cl1 = " << cl1 << endl;
   cout << "The right-side complex number is cr1 = " << cr1 << endl;
   cout << "Difference of two complex numbers is: cs1 = " << cs1 << endl;
   double abscs1 = abs ( cs1 );
   double argcs1 = arg ( cs1 );
   cout << "The modulus of cs1 is: " << abscs1 << endl;
   cout << "The argument of cs1 is: "<< argcs1 << " radians, which is " 
        << argcs1 * 180 / pi << " degrees." << endl << endl; 

   // Example of the second member function
   // type complex<double> minus type double
   complex <double> cl2 ( 3.0 , 4.0 );
   double cr2 =5.0;
   complex <double> cs2 = cl2 - cr2;

   cout << "The left-side complex number is cl2 = " << cl2 << endl;
   cout << "The right-side complex number is cr2 = " << cr2 << endl;
   cout << "Difference of two complex numbers is: cs2 = " << cs2 << endl;
   double abscs2 = abs ( cs2 );
   double argcs2 = arg ( cs2 );
   cout << "The modulus of cs2 is: " << abscs2 << endl;
   cout << "The argument of cs2 is: "<< argcs2 << " radians, which is " 
        << argcs2 * 180 / pi << " degrees." << endl << endl;

   // Example of the third member function
   // type double minus type complex<double>
   double cl3 = 5.0;
   complex <double> cr3 ( 3.0 , 4.0 );
   complex <double> cs3 = cl3 - cr3;

   cout << "The left-side complex number is cl3 = " << cl3 << endl;
   cout << "The right-side complex number is cr3 = " << cr3 << endl;
   cout << "Difference of two complex numbers is: cs3 = " << cs3 << endl;
   double abscs3 = abs ( cs3 );
   double argcs3 = arg ( cs3 );
   cout << "The modulus of cs3 is: " << abscs3 << endl;
   cout << "The argument of cs3 is: "<< argcs3 << " radians, which is " 
        << argcs3 * 180 / pi << " degrees." << endl << endl; 

   // Example of the fourth member function
   // minus type complex<double>
   complex <double> cr4 ( 3.0 , 4.0 );
   complex <double> cs4 = - cr4;

   cout << "The right-side complex number is cr4 = " << cr4 << endl;
   cout << "The result of the unary application of - to the right-side"
        << "\n complex number is: cs4 = " << cs4 << endl;
   double abscs4 = abs ( cs4 );
   double argcs4 = arg ( cs4 );
   cout << "The modulus of cs4 is: " << abscs4 << endl;
   cout << "The argument of cs4 is: "<< argcs4 << " radians, which is " 
        << argcs4 * 180 / pi << " degrees." << endl << endl;  
}
  
  
  
  

요구 사항

헤더: <complex>

네임 스페이스: std