Arne Mertz describes in a series of articles the principles of operator overloading.
Operator Overloading
Operator Overloading: Common Practice
by Arne Mertz
From the articles:
Operators can be used to make user defined classes act like known types, e.g. like numbers, pointers and iterators. That way they facilitate the usage of those classes. They can also be used to make your objects do whatever you want them to do, for example build structures that save the operations for later evaluation. The latter is especially useful for building embedded DSLs and gives enough subject matter for a whole series of blog posts. [The first] post will cover the former use of operator overloading, i.e. writing operators that behave like “normal” operators.
... In [the second] post I will go into the details and write a bit about each operator and how a straight forward implementation might look if the operator is meant to work similar to built in operators.
Add a Comment
Comments are closed.