다음을 통해 공유


complex<long double>

이 명시적으로 특수화된 클래스 템플릿은 순서가 지정된 개체 쌍을 저장하는 개체를 설명합니다. 두 형식 long double모두, 첫 번째는 복소수의 실제 부분을 나타내고 두 번째는 허수 부분을 나타냅니다.

구문

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

complex(
    constexpr complex<long double>& complexNum);

// rest same as class template complex
};

매개 변수

_RealVal
생성되는 복소수의 실제 부분에 대한 형식 long double 값입니다.

_ImagVal
생성되고 있는 복소수의 허수 부분에 대한 long double 형식의 값입니다.

complexNum
생성되는 형식 doublefloat 의 복소수를 초기화하는 데 실제 및 허수 부분을 사용하는 형식 또는 형식 long double 의 복소수입니다.

Return Value

long double 형식의 복소수입니다.

설명

형식의 복합 클래스에 대한 클래스 템플릿 complexlong double 명시적 특수화는 클래스 템플릿이 정의하는 생성자에서만 클래스 템플릿과 다릅니다. 변환 long doublefloat 을 암시적으로 사용할 수 있지만 doublelong double 변환할 수 있어야 explicit합니다. 할당 구문을 사용하여 형식 변환을 사용하여 시작에 대한 규칙을 사용합니다 explicit .

클래스 템플릿 complex 및 해당 멤버에 대한 자세한 내용은 복합 클래스를 참조 하세요.

Microsoft 관련: 형식과 double 형식의 long double 표현은 동일하지만 고유한 형식입니다. 자세한 내용은 기본 제공 형식을 참조 하세요.

예시

// complex_comp_ld.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<long double> c1( 4.0 , 5.0 );
    cout << "Specifying initial real & imaginary parts,\n"
        << " as type float 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( 1.0 , 3.0 );
    complex<long double> c2longdouble ( c2float );
    cout << "Implicit conversion from type float to type long double,"
        << "\n gives c2longdouble = " << c2longdouble << endl;

    // The third constructor initializes values of the real &
    // imaginary parts using those of a complex number
    // of type double
    complex<double> c3double( 3.0 , 4.0 );
    complex<long double> c3longdouble( c3double );
    cout << "Implicit conversion from type long double to type float,"
        << "\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;
}
Specifying initial real & imaginary parts,
as type float gives c1 = (4,5)
Implicit conversion from type float to type long double,
gives c2longdouble = (1,3)
Implicit conversion from type long double to type float,
gives c3longdouble = (3,4)
The modulus of c3 is recovered from c3 using: abs( c3 ) = 5
Argument of c3 is recovered from c3 using:
arg( c3 ) = 0.927295 radians, which is 53.1301 degrees.

요구 사항

헤더: <복합>

네임스페이스: std

참고 항목

complex 클래스
C++ 표준 라이브러리의 스레드 보안