How do you implement a UTIL class in C++?

Started by
1 comment, last by NotAYakk 14 years, 10 months ago
Hi friends! I'd like to know how do you implement usually UTIL classes or methods (where instancing is not necessary). I guess I should use namespaces, but not sure. Suggestions? Thanks in advance.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
You could create a class with nothing but static methods, but at that point you may as well just create free functions, optionally inside a namespace.
Well, having it inside a struct or class does give you the ability to have private, public and protected static functions.

But that can usually be dealt with by different header-file/cpp-file based interfaces just as easily (or more so).

Templates, however, cannot be easily duplicated. Traits classes are basically templated namespaces that can differ based on the type and can be reopened-by-specialisation by clients.

This topic is closed to new replies.

Advertisement