operator== (<complex>)
두 복소수의 하나 또는 둘 다 같은지 테스트 실수부와 허수부 파트 형식의 하위 집합에 속할 수 있습니다.
template<class Type>
bool operator==(
const complex<Type>& _Left,
const complex<Type>& _Right
);
template<class Type>
bool operator==(
const complex<Type>& _Left,
const Type& _Right
);
template<class Type>
bool operator==(
const Type& _Left,
const complex<Type>& _Right
);
매개 변수
_Left
복잡 한 숫자 또는 개체 형식의 매개 변수 값이 같지 않은지 테스트 합니다._Right
복잡 한 숫자 또는 개체 형식의 매개 변수 값이 같지 않은지 테스트 합니다.
반환 값
true 이면 번호 같으면. false 이면 번호 같은 경우.
설명
두 복소수는 실제 부품 같은지 및 허수 부분이 같은지 경우에 같습니다.그렇지 않으면 두 개체는 서로 다른 개체입니다.
비교 테스트 데이터를 특정 형식으로 변환 하지 않고 실행 될 수 있도록 작업 오버 로드 됩니다.
예제
// complex_op_EQ.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> compared with type complex<double>
complex <double> cl1 ( polar ( 3.0 , pi / 6 ) );
complex <double> cr1a ( polar ( 3.0 , pi /6 ) );
complex <double> cr1b ( polar ( 2.0 , pi / 3 ) );
cout << "The left-side complex number is cl1 = " << cl1 << endl;
cout << "The 1st right-side complex number is cr1a = " << cr1a << endl;
cout << "The 2nd right-side complex number is cr1b = " << cr1b << endl;
if ( cl1 == cr1a )
cout << "The complex numbers cl1 & cr1a are equal." << endl;
else
cout << "The complex numbers cl1 & cr1a are not equal." << endl;
if ( cl1 == cr1b )
cout << "The complex numbers cl1 & cr1b are equal." << endl;
else
cout << "The complex numbers cl1 & cr1b are not equal." << endl;
cout << endl;
// Example of the second member function
// type complex<int> compared with type int
complex <int> cl2a ( 3 , 4 );
complex <int> cl2b ( 5 ,0 );
int cr2a =3;
int cr2b =5;
cout << "The 1st left-side complex number is cl2a = " << cl2a << endl;
cout << "The 1st right-side complex number is cr2a = " << cr2a << endl;
if ( cl2a == cr2a )
cout << "The complex numbers cl2a & cr2a are equal." << endl;
else
cout << "The complex numbers cl2a & cr2a are not equal." << endl;
cout << "The 2nd left-side complex number is cl2b = " << cl2b << endl;
cout << "The 2nd right-side complex number is cr2b = " << cr2b << endl;
if ( cl2b == cr2b )
cout << "The complex numbers cl2b & cr2b are equal." << endl;
else
cout << "The complex numbers cl2b & cr2b are not equal." << endl;
cout << endl;
// Example of the third member function
// type double compared with type complex<double>
double cl3a =3;
double cl3b =5;
complex <double> cr3a (3 , 4 );
complex <double> cr3b (5 ,0 );
cout << "The 1st left-side complex number is cl3a = " << cl3a << endl;
cout << "The 1st right-side complex number is cr3a = " << cr3a << endl;
if ( cl3a == cr3a )
cout << "The complex numbers cl3a & cr3a are equal." << endl;
else
cout << "The complex numbers cl3a & cr3a are not equal." << endl;
cout << "The 2nd left-side complex number is cl3b = " << cl3b << endl;
cout << "The 2nd right-side complex number is cr3b = " << cr3b << endl;
if ( cl3b == cr3b )
cout << "The complex numbers cl3b & cr3b are equal." << endl;
else
cout << "The complex numbers cl3b & cr3b are not equal." << endl;
cout << endl;
}
요구 사항
헤더: <complex>
네임 스페이스: std