I already read a lot of posts and articles all over the net, but I couldn't find a definite answer about this.
I have some functions with similar purposes that I want to have out of the global scope. Some of them need to be public, others should be private (because they are only helper functions for the "public" ones). Additionally, I don't have only functions, but also variables. They are only needed by the "private" helper functions and should be private, too.
Now there are the three ways:
- making a class with everything being static (contra: potential "Cannot call member function without object" - not everything needs to be static)
- making a singleton class (contra: I WILL need the object)
- making a namespace (no private keyword - why should I put it in a namespace at all, then?)
What would be the way to take for me? Possible way of combining some of these ways?
I thought of something like:
- making a singleton, the static functions use the helper function of the singleton object (is this possible? I'm still within the class, but accessing an object of it's type)
- constructor called at programm start, initializes everything (-> making sure the statics can access the functions from the singleton object)
- access the public functions only through MyClass::PublicStaticFunction()
Thanks.