To provide a functionality for a class cls, say, 'add', following are the types I decided:
struct add
{
add sum(add other) { ... }
};
vs.
template<typename Add>
Add sum(Add one, Add two) { ... }
Which approach should be preferred, what advantages do the first have over the second and vice versa?
Which approach should be preferred, what advantages do the first have over the second and vice versa?
I believe the question does not have a straightforward answer. I think this goes down to the Generic Vs Object Oriented Programming battle.
See also On the Tension Between Object-Oriented and Generic Programming in C++.