Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Equality operators:
Syntax
expression
==expression
expression!=expression
Remarks
The equal-to operator (==) returns true if both operands have the same value; otherwise false.
The not-equal-to operator (!=) returns true if the operands don't have the same value; otherwise false.
In C and C++, not_eq can be used as alternative to !=. For more information, see not-eq.
Example
#include <iostream>
int main()
{
int x = 1, y = 1, z = 2;
if (x == y)
{
std::cout << "Equal\n";
}
if (x != z)
{
std::cout << "Not equal\n";
}
}
Equal
Not equal
See also
not-eq
Operator overloading
Expressions with binary operators
C++ built-in operators, precedence; and associativity
C relational and equality operators