complex - STL C++

operator<<()

Declaration

template <class X, class XCharType, class XTraits>
basic_ostream<XCharType, XTraits>& operator<<(basic_ostream<XCharType, XTraits>& qrOutStream,
                                              const complex<X>& kqrZ);

Description

This friend funciton is the overloaded insertion operator for the complex numnbers class. The output is given in the format (x,y), where x and y are the real and imaginary parts of kqrZ, respectively.

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

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

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

Output

operator<<() Output
 

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