complex<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
    值构造的复数的重载的 浮动 类型。

  • _ImagVal
    值构造的复数的虚部的 浮动 类型。

  • _ComplexNum
    double 类型复数物理和虚部用于初始化类型构造的 浮动 复数形式的或类型 long double。

返回值

复数 浮动类型。

备注

模板类的显式专用化复杂到 浮动 类型复杂的类与它定义的模板仅类不同于构造函数。 浮动double 允许从转换是隐式的,但是,要求 long double 到从 浮动 的更不安全转换为 explicit。 使用分配语法,使用 explicit 排除与类型转换的启动。

有关类模板 complex的更多信息,请参见 complex 类。 有关 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;
}
  

要求

标题: <复杂>

命名空间: std

请参见

参考

complex 类

C++ 标准库中的线程安全

其他资源

complex 成员

复杂成员