On 2007-09-05 11:02, v4vijayakumar wrote:
When (at which phase of the software development) the decision would
usually be taken to overload operators? Will you first design with
functions and then move these functionalities to overloaded operators?
The decision to use operator overloading can usually be taken when
designing the classes. Classes represents concepts, so when you have a
clear picture of what concepts you'll be modelling ask yourself: "Would
A = B @ C, make sense to someone not part of the development team?",
where A, B, and C are concepts and @ an operator?
If the answer is "yes" then you can overload that operator,if it is "no"
you should think twice before overloading that operator for those classes.
When we can surely say, we need a functor here, or, predicate here,
for example?
This is, in my opinion, a lower level decision since the need for a
predicate or functor is connected to the algorithms used. So this is
more an implementation question than a design question.
--
Erik Wikström