Is it bad practice to use a class of static members for hiding helper functions?

Is it bad practice to use a class of only static members to hide helper functions? I have a visibleFunction() that uses helper1() and helper2(). There's only 1 instance of each function. I want to keep the helper functions private.

1
2
3
4
5
6
7
8
9
class MyClass
{
    public:
        static void visibleFunction();
    private:
        static bool helper1();
        static void helper2();
        /* plus some other static variables */
}
Last edited on
Consider using namespaces; an unnamed namespace provides stronger (complete) encapsulation.

header:
namespace utility { void visibleFunction(); }

implementation:
1
2
3
4
5
6
7
8
9
10
11
12
namespace utility 
{
       namespace // unnamed namespace: members have internal linkage
       {
            // these are not programatically visible outside this translation unit
            bool helper1() { /* ... */ } 
            void helper2() { /* ... */ }
            // variables 
       }

       void visibleFunction() { /* ... */ }
}
Thank you!
Topic archived. No new replies allowed.