complex - STL C++

complex<X>::imag()

Declaration

void complex<X>::imag();

Description

This is the imag() function for the complex class template. This function returns the imaginary 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 imaginary part
	cout << "The imaginary part is "<< qZ.imag() << endl;

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

Output

complex<X>::imag() Output
 

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