Appendex A. Operators
The table in this appendix lists and describes the many operators of the C++ language. Many of these operators are available for overloading in your classes.
When overloading the operators, you are not restricted to the types indicated here. Often the type will be your class. You can also overload any infix operator more than once to work with different types, but remember that the return type is not part of what differentiates two overloads.
Operator | Name/Meaning | Works On | Overload | Example | Reads As |
---|---|---|---|---|---|
Arithmetic Operators | |||||
+ | Add | Numeric and char | Y | a+b | Add a and b to produce a result |
- | Subtract | Numeric and char | Y | a-b | Subtract b from a to produce a result |
* | Multiply | Numeric and char | Y | a*b | Multiply a by b to produce a result |
Get SAMS Teach Yourself C++ in 10 Minutes SECOND 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.