complex<double>
存储描述了排序的对象对两个 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
值构造的复数的重载的 double 类型。_ImagVal
值构造的复数的虚部的 double 类型。_ComplexNum
浮动 类型复数物理和虚部用于初始化类型构造的 double 复数形式的或类型 long double。
返回值
复数 double类型。
备注
模板类的显式专用化复杂到 double 类型复杂的类与它定义的模板仅类不同于构造函数。 浮动 的 double 允许从转换是隐式的,但是,从 long double 到 double 要求的转换为 explicit。 使用分配语法,使用 explicit 排除与类型转换的启动。
有关类模板 complex的更多信息,请参见 complex 类。 有关 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;
}
要求
标题: <复杂>
命名空间: std