complex - STL C++

complex<X>::value_type

Declaration

typedef X complex<X>::value_type;

Description

This is a type definition of the data type value_type for the complex class template. This is used to define the type that is used as the real and imaginary parts of the complex number.

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create a complex number
	complex<double> qZ(2.0, 4.0);
	cout << "Complex Number : "<< qZ << endl;

	// Get the real part
	complex<double>::value_type qReal = qZ.real();
	cout << "The real part is "<< qReal << endl;

	// Get the imaginary part
	complex<double>::value_type qImag = qZ.imag();
	cout << "The imaginary part is "<< qImag << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

complex<X>::value_type Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.