Notes / C++ / Operators

Operators in C++ — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Operators C++ has the same core operator families as C — arithmetic, relational, logical, and assignment — plus a powerful extra feature: operator overloading, which lets you redefine what operators like + do for your own classes..

Syntax

syntax
a + b   a - b   a * b   a / b   a % b
a == b  a != b  a > b   a < b
a && b  a || b  !a

Example

cpp
#include <iostream>
using namespace std;

int main() {
    int a = 10, b = 3;
    cout << "Sum: " << (a + b) << endl;
    cout << "Remainder: " << (a % b) << endl;
    cout << "Greater: " << (a > b) << endl;
    return 0;
}

Output

outputSum: 13 Remainder: 1 Greater: 1

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview "What is operator overloading?" is a very common C++ interview question — be ready with a one-line definition and a small example.
Back to notes Read full lesson →