Category

Operator Overloading

Introduction to Operator Overloading

What is operator overloading? Operator overloading is the practice of assigning new meaning to existing C++ operators when they are used with user defined types…

Jul 15, 2026 →

Arithmetic and Comparison Operators

Overloaded arithmetic and comparison operators are used the most frequently. When it's obvious that an object represents a value that's added, subtracted, or co…

Jul 15, 2026 →

Assignment Operators

Assignment operators differ from the arithmetic operators previously shown. The expression a + b returns a new value and leaves a and b unchanged; the expressio…

Jul 15, 2026 →

Stream Input and Output Operators

The stream input and output operators allow the standard I/O operators of std::cin, std::cout, and the other standard streams to operate on user defined types.…

Jul 15, 2026 →

Subscript and Function Call Operators

Subscript and Function Call Operators The subscript operator [] and the function call operator () allow a class object to behave like an array or like a functio…

Jul 15, 2026 →

Conversion Operators

A conversion operator allows your class objects to be implicitly converted to other types. They are defined like normal member functions, but are named: operato…

Jul 15, 2026 →

The Three-Way Comparison Operator

The three way comparison operator, written as <=> and commonly known as the spaceship operator, was introduced in C++20. One call of the operator will determine…

Jul 15, 2026 →

When Operator Overloading Should Be Avoided

Operator overloading can be incredibly useful, and equally easily misused. As soon as an overloaded operator doesn’t represent the intuitive meaning of its symb…

Jul 15, 2026 →
About CppLearn

CppLearn is an interactive, free reference for modern C++. In each lesson, you'll find out how the language works, rather than just lines of code that you can copy and paste. We cover concepts starting from beginner lessons on fundamentals and proceed to templates, move semantics, smart pointers, and areas that usually trap or scare C++ learners.