Let's say I have, or am going to write, a set of related functions. Let's say they're math-related. Organizationally, should I:
- Write these functions and put them in my
MyMath
namespace and refer to them viaMyMath::XYZ()
- Create a class called
MyMath
and make these methods static and refer to the similarlyMyMath::XYZ()
Why would I choose one over the other as a means of organizing my software?
Otherwise, use namespaced functions.
In response to the comments: yes, static methods and static data tend to be over-used. That's why I offered only two, related scenarios where I think they can be helpful. In the OP's specific example (a set of math routines), if he wanted the ability to specify parameters - say, a core data type and output precision - that would be applied to all routines, he might do something like:
If you don't need that, then by all means use a namespace.