complex - STL C++

operator!=()

Declaration

bool operator!=(const complex<X>& kqrZ1, const complex<X>& kqrZ2);

Description

This friend function is the overloaded not equal to operator for the complex class. This operator returns true if kqrZ1 and kqrZ2 are not equal and false otherwise. The overloaded versions allow a complex number to be compared to the real number parameter type.

Header Include

#include <complex>

Overloads

bool operator!=(const complex<X>& kqrZ, const X& kxrX);

bool operator!=(const X& kxrX, const complex<X>& kqrZ);

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create two complex numbers and compare them
	complex<double> qZ1(2.0, 4.0);
	complex<double> qZ2(1.0, 1.0);
	cout << qZ1 << (qZ1 != qZ1 ? " is not" : " is") << " equal to " << qZ1 << endl;
	cout << qZ1 << (qZ1 != qZ2 ? " is not" : " is") << " equal to " << qZ2 << endl;
	cout << qZ2 << (qZ2 != qZ2 ? " is not" : " is") << " equal to " << qZ2 << endl;

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

Output

operator!=() Output
 

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