Instead of putting a bunch of related static functions into a class I want to just group them under a namespace instead. Is it possible to split the function declarations and definitions across files as with a class(i.e., put all the declarations in a .h file and all the definitions in a .cpp file), and if so, is there any special syntax required? Is this even the appropriate approach to handling the grouping of related static-only functions?
Why do you want to do that? Don't forget that the name of your class also works as a namespace. You can easily tell the difference between a static and a member function call because the latter must be called from an object.
I vaguely remember reading a recommendation to use a namespace instead of a class to group functions if all the functions are static. I don't have a personal preference, so I could just as easily use a class, instead.
What exactly do you want to do? You want these functions to be part of a class or not? What I understood from your first post is that you have a bunch of related functions and you want to decide if you'll put them inside a class as static functions or inside a plain namespace.
m4ster r0shi,
yes, that is what I was asking. My inclination would be to put them in a class, but I remember someone saying that it's unnecessary to create an new class whose only purpose would be to contain static functions. So that's why I opted to try a namespace instead, and that's why I was wondering if a namespace could/should be constructed similarly to a class, with a split declaration and definition.
If the functions are to be accessible to users of the class, then I'd leave them as static members of
the class. If the functions are not to be accessible to users of the class, then I'd move them entirely
to an unnamed namespace in the .cpp file and the header file make no mention of them. If they're
not usable by the user, then the user should have to see them.