complex - STL C++

complex<X>::real()

Declaration

void complex<X>::real();

Description

This is the real() function for the complex class template. This function returns the real part 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;

	// Output the real part
	cout << "The real part is "<< qZ.real() << endl;

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

Output

complex<X>::real() Output
 

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