complex<float>

描述存储的顺序对对象两个类型 float*,* 第一个表示复数的实部和第二个表示虚拟部分的对象。

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

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

参数

  • _RealVal
    类型 float 的值构造的复数的实部的。

  • _ImagVal
    类型 float 的值构造的复数的虚拟部分。

  • _ComplexNum
    类型 二进制文件 的复数物理和虚拟部分用于初始化类型构造的 float 的一个复数的或的类型 long double 。

返回值

类型 float的一个复数。

备注

模板类复杂的显式专用化到类型 float 复杂类的与它所定义的模板仅类不同于构造函数。从 float 的转换到 二进制文件 允许是隐式的,但是,到 long double 需要从 float 的较不安全的转换非常 显式。使用分配语法,使用 显式 排除进行类型转换时的激活。

有关模板类 complex的更多信息,请参见 complex Class。有关模板类 complex的成员列表,请参见 复杂成员

示例

// complex_comp_flt.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 <float> 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 double
   complex <double> c2double ( 1.0 , 3.0 );
   complex <float> c2float ( c2double );
   cout << "Implicit conversion from type double to type float,"
        << "\n gives c2float = " << c2float << 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 ( 3.0 , 4.0 );
   complex <float> c3float ( c3longdouble );
   cout << "Explicit conversion from type long double to type float,"
        << "\n gives c3float = " << c3float << endl;

   // The modulus and argument of a complex number can be recovered
   double absc3 = abs ( c3float);
   double argc3 = arg ( c3float);
   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

命名空间: std

请参见

参考

complex Class

线程安全性对标准C++库中

其他资源

complex 成员

复杂成员