次の方法で共有


complex<float>

オブジェクト型 フローティング ことを示し 1 番複素数の実数部と 2 番目のオブジェクトのペアが格納された順序として表す部分を表します。

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
    倍精度浮動小数点型 構築された型 フローティング の複合型を初期化するために実際つまり部分に使用される複合型または型の long double。

戻り値

フローティング の複合型。

解説

フローティング の複雑なクラスへのテンプレート クラスの複合の明示的な特殊化にはコンストラクター内でしか定義するテンプレート クラスとは異なります。 フローティング から 倍精度浮動小数点型 への変換が暗黙的ですが フローティング から long double によりも安全な変換は 明示 である必要があります。 明示 の使用はの構文を使用して型変換で開始を除外します。

テンプレート クラス 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> メンバー

複雑なメンバー