分配编号为目标群数字,分配的数字可以是复杂或类型与它分配复数的物理和虚拟部分。
template<class Other>
complex<Type>& operator=(
const complex<Other>& _Right
);
complex<Type>& operator=(
const Type& _Right
);
参数
- _Right
一个复数或与目标群数字相同的参数数目。
返回值
指派为参数指定的数字的一个复数。
备注
重载操作,以便简单算术运算可以执行,而无需数据转换为特定格式。
示例
// complex_op_as.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> assigned to 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;
cl1 = cr1;
cout << "The complex number cr1 assigned to the complex number cl1 is:"
<< "\n cl1 = cr1 = " << cl1 << endl;
// Example of the second member function
// type double assigned to type complex<double>
complex <double> cl2 ( -2 , 4 );
double cr2 =5.0;
cout << "The left-side complex number is cl2 = " << cl2 << endl;
cout << "The right-side complex number is cr2 = " << cr2 << endl;
cl2 = cr2;
cout << "The complex number cr2 assigned to the complex number cl2 is:"
<< "\n cl2 = cr2 = " << cl2 << endl;
cl2 = complex<double>(3.0, 4.0);
cout << "The complex number (3, 4) assigned to the complex number cl2 is:"
<< "\n cl2 = " << cl2 << endl;
}
要求
标头: <complex>
命名空间: std