Lesson 5 of 45
C++Lesson 5: Operators
9 min
Course progress11%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 5 of 45
C++9 min
Keep these ideas in mind as you work through the lesson.
C++ overloads several families of operators that let you express arithmetic, comparisons, and bit‑level manipulations succinctly. The core families are:
+ - * / %< > <= >= == !=&& || !& | ^ ~ << >>=, +=, -=, *=, /=, %= and their bitwise counterparts.?: (conditional), sizeof, typeid, , (comma).int a = 5, b = 2;
std::cout << \"a + b = \" << (a + b) << \"\
\"; // 7
std::cout << \"a << 1 = \" << (a << 1) << \"\
\"; // 10 (binary shift)
std::cout << \"(a > b) ? a : b = \" << ((a > b) ? a : b) << \"\
\";
Tip: Beware of operator precedence – use parentheses to make intent explicit.