How do you implement a UTIL class in C++?
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.
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.
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
Popular Topics
Advertisement