Jump to content
  • Advertisement
Sign in to follow this  
riruilo

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

This topic is 3361 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!