Operators in C++

From the C++ cheat sheet · Operators · verified Jul 2026

Operators

The everyday operator set.

cpp
// Quick Reference
+  -  *  /  %           // arithmetic
== != <  >  <= >=       // comparison
&& ||  !                // logical
&  |  ^  ~  << >>        // bitwise
cond ? a : b            // ternary
💡 Integer division truncates; make one operand floating-point for a real quotient.
⚡ && and || short-circuit - the right operand is skipped when the result is known.
📌 Bitwise ops (& | ^ << >>) work on the binary representation, not logic (&& ||).
🟢 Prefix ++n avoids a copy vs postfix n++ - relevant for heavy iterator types.
operators
Back to the full C++ cheat sheet