Cpp-standard-library-cpp-complex-real
提供:Dev Guides
C ++複雑なライブラリ-リアル
説明
複素数の実数部に使用され、複素数xの実数部を返します。
宣言
- 以下は、std
- realの宣言です。
template<class T> T real (const complex<T>& x);
C 11
template<class T> T real (const complex<T>& x);
パラメーター
*x* -複素数値です。
戻り値
複素数xの実部を返します。
例外
none
例
- 以下のstd
- realの例。
#include <iostream>
#include <complex>
int main () {
std::complex<double> mycomplex (50.0,1.0);
std::cout << "Real part is: " << std::real(mycomplex) << '\n';
return 0;
}
サンプル出力は次のようになります-
Real part is: 50