

^ a b According to the C99 standard, the right shift of a negative number is implementation defined.^ a b In the context of iostreams in C++, writers often will refer to > as the "put-to" or "stream insertion" and "get-from" or "stream extraction" operators, respectively.For brevity, only the forms that use only trigraphs and neither are provided. ^ Since trigraphs are simply substituted by the preprocessor, the different representations of the characters in this operator can be mixed and matched in any way.They are still available in C as of C17 but will be removed in C23. ^ a b c d e f g h i Trigraphs were removed in C++17.^ a b c d e f g h i j k l Requires iso646.h in C.^ The modulus operator works just with integer operands, for floating point numbers a library function must be used instead (like ]).Note: for user-defined conversions, the return type implicitly and necessarily matches the operator name unless the type is inferred ( operator auto ()/ operator decltype ( auto )()). Note: behaves like const_cast/static_cast/reinterpret_cast Member of object a selected by pointer-to-member b Member selected by pointer-to-member b of object pointed to by a Structure reference ("member b of object a") Structure dereference ("member b of object pointed to by a") Member and pointer operators Operator name Operator nameĪll bitwise operators exist in C and C++ and can be overloaded in C++.Īll assignment expressions exist in C and C++ and can be overloaded in C++.įor the given operators the semantic of the built-in combined assignment expression a ⊚= b is equivalent to a = a ⊚ b, except that a is evaluated only once. The operator has a total of 3 possible return types: std::weak_ordering, std::strong_ordering and std::partial_ordering to which they all are convertible to.Īll logical operators exist in C and C++ and can be overloaded in C++, albeit the overloading of the logical AND and logical OR is discouraged, because as overloaded operators they behave as ordinary function calls, which means that both of their operands are evaluated, so they lose their well-used and expected short-circuit evaluation property. Operator nameīool K :: operator = ( S const & b ) const īool operator = ( K const & a, S const & b ) īool K :: operator != ( S const & b ) const īool operator != ( K const & a, S const & b ) īool K :: operator > ( S const & b ) const īool operator > ( K const & a, S const & b ) īool K :: operator >= ( S const & b ) const īool operator >= ( K const & a, S const & b ) Īuto operator ( const K & a, const S & b ) Since C++20, the inequality operator is automatically generated if operator= is defined and all four relational operators are automatically generated if operator is defined. Note: C++ uses the unnamed dummy-parameter int to differentiate between prefix and postfix decrement operators.Ĭomparison operators/relational operators Īll comparison operators can be overloaded in C++. Note: C++ uses the unnamed dummy-parameter int to differentiate between prefix and postfix increment operators. R, S and T stand for any type(s), and K for a class type or enumerated type.Īll arithmetic operators exist in C and C++ and can be overloaded in C++. Most of the operators available in C and C++ are also available in other C-family languages such as C#, D, Java, Perl, and PHP with the same precedence, associativity, and semantics.įor the purposes of these tables, a, b, and c represent valid values (literals, values from variables, or return value), object names, or lvalues, as appropriate. The formatting of these operators means that their precedence level is unimportant. When not overloaded, for the operators &, ||, and, (the comma operator), there is a sequence point after the evaluation of the first operand.Ĭ++ also contains the type conversion operators const_cast, static_cast, dynamic_cast, and reinterpret_cast. Note that C does not support operator overloading.

All the operators listed exist in C++ the column "Included in C", states whether an operator is also present in C. This is a list of operators in the C and C++ programming languages. Similar syntax in both computer languages
