다음을 통해 공유


complex<double>

개체 형식의 정렬 된 쌍을 저장 하는 개체에 설명 합니다. 이중*,* 는 먼저 복잡 한 숫자와 두 번째의 실제 부분을 나타내는 가상의 일부를 나타내는.

template<>
   class complex<double> {
public:
   complex(
      double _RealVal = 0, 
      double _ImagVal = 0
   );

   complex(
      const complex<double>& _ComplexNum
   );
   explicit complex(
      const complex<long double>& _ComplexNum
   );
   // rest same as template class complex
};

매개 변수

  • _RealVal
    형식의 값을 이중 실제 부품의 복잡 한 구성 되 고 수 있습니다.

  • _ImagVal
    형식의 값을 이중 구성 되 고 복소수의 허수 부분에 대 한.

  • _ComplexNum
    복잡 한 숫자 형식 부동 소수점 또는 종류의 long double 는 실수부와 허수부 파트 형식의 복소수를 초기화 하는 데 사용 됩니다 이중 구성 되 고.

반환 값

복소수 형식의 이중.

설명

명시적 특수화는 복합 형식 클래스에 복잡 한 템플릿 클래스의 이중 템플릿 클래스 정의 생성자와 다릅니다.변환 float이중 암시적으로 호출할 수 있지만 변환 long double 에 이중 될 하는 데 필요한 명시적.사용 하는 명시적 out 시작 규칙을 할당 구문을 사용 하 여 형식 변환을 사용 합니다.

템플릿 클래스에 대 한 자세한 내용은 complex를 참조 하십시오 complex Class.템플릿 클래스의 구성원에 대 한 complex를 참조 하십시오 복잡 한 구성원.

예제

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

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

   // The first constructor specifies real & imaginary parts
   complex <double> c1 ( 4.0 , 5.0 );
   cout << "Specifying initial real & imaginary parts,\n"
        << " as type double gives c1 = " << c1 << endl;

   // The second constructor initializes values of the real &
   // imaginary parts using those of complex number of type float
   complex <float> c2float ( 4.0 , 5.0 );
   complex <double> c2double ( c2float );
   cout << "Implicit conversion from type float to type double,"
        << "\n gives c2double = " << c2double << endl;

   // The third constructor initializes values of the real &
   // imaginary parts using those of a complex number
   // of type long double
   complex <long double> c3longdouble ( 4.0 , 5.0 );
   complex <double> c3double ( c3longdouble );
   cout << "Explicit conversion from type float to type double,"
        << "\n gives c3longdouble = " << c3longdouble << endl;

   // The modulus and argument of a complex number can be recovered
   double absc3 = abs ( c3longdouble );
   double argc3 = arg ( c3longdouble );
   cout << "The modulus of c3 is recovered from c3 using: abs ( c3 ) = "
        << absc3 << endl;
   cout << "Argument of c3 is recovered from c3 using:\n arg ( c3 ) = "
        << argc3 << " radians, which is " << argc3 * 180 / pi
        << " degrees." << endl;
}
  

요구 사항

헤더: <complex>

네임 스페이스: 국방 표준

참고 항목

참조

complex Class

표준 C++ 라이브러리에서 스레드로부터의 안전성

기타 리소스

<complex> 멤버

복잡 한 구성원