|
Re: The Positive Legacy of C++ and Java
|
Posted: Apr 7, 2009 1:36 AM
|
|
The downside of not having operator overloading is that you are then saddled with having to impose (and police) a standard naming convention if you are to ever create a usable generic system such as C++'s STL. The fact that I can overload the ++ and -- operators of my image class iterators vastly simplifies the writing of generic algorithms. Furthermore, it enables ANY algorithm written by a third party, with no knowledge of my classes, to create a compatible algorithm. It also allows many flavours of iterator to be created (up/down, left/right, diagonal, spiral, your name in cursive script) and have them implicitly compatible too. The major benefit of operator overloading is to make the interface to your class simple, leaving the complexity of the implementation to the author of the class. With proper design, the maintainer will normally only have to deal with the usage of the class, not its implementation. Throwing out operator overloading because 'some people don't get it' is akin to banning hardware stores from selling professional tools because some numpty DIYers may not know how to use them properly.
|
|