Chapter 13. Operator Types and Operator Overloading

Although operators exist in C programming, they take on new meaning in C++ because they can be programmed to function on user-defined types such as classes, and they can also be overloaded.

In this lesson, you will learn

  • Using the operator keyword

  • Unary and binary operators

  • Conversion operators

  • Operators that cannot be redefined

What Are Operators in C++?

On a syntactical level, there is very little that differentiates an operator from a function, save for the usage of the keyword operator. An operator declaration looks quite like a function declaration:

return_type operator operator_symbol (...parameter list...);

The operator_symbol in this case could be any of the several operator-types that the programmer ...

Get Sams Teach Yourself C++ in One Hour a Day, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.