complex - STL C++

complex<X>::complex()

Declaration

template <class X>
complex<X>::complex();

Description

This is the constructor for the complex class template.

Header Include

#include <complex>

Overloads

template<class X>
complex(const X& kxrReal = 0, const X& kxrImag = 0);

template<class X>
complex(const complex<X>& kqrZ);

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create a complex number
	complex<int> qComplex(2, 4);
	cout << "Complex Number : "<< qComplex << endl;

	// Create a complex number with the copy constructor
	complex<int> qCopy(qComplex);
	cout << "Copy of Complex Number : "<< qCopy << endl;

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

Output

complex<X>::complex() Output
 

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