Search code examples
c++utilities

How to design a utility class?


But I don't know if I should go for static methods, just a header, a class, or something else?

What would be best practice? But, I don't want to have an instance of a utility class.

I want to add functions like:

Uint32 MapRGB (int r, int g, int b);
const char* CopyString(const char* char);
// etc. You know: utility methods...

Solution

  • Don't put them in a class; just make them non-member functions at namespace scope.

    There's no rule that says every function has to be a member function of some class.