1) I have created a class that contains only static methods.
Is such a class useful, or should I replace it with a namespace ?
2) In that class, I have created a const array member variable (also static).
I had to redeclare in the cpp, then I have a function to fill it. (also a bool to check if it is initialized)
void ThatClass::initializeArray()
{
if (!arrayInitialized)
initailizeIt();
else
qDebug("was initialized");
}
If I run the function more than once, I get the debug message, which tells me that the class is being held in memory (even though I never explicitly called its constructor and I am not holding it in the caller explicitly).
In this case, it seems worth using a class instead of a namespace....
EXCEPT...
Wouldn't it be more effective to have a namespace, and for the function that requires the specific const, to have either a namespace level const or a const inside the function ?
I am concerned by memory usage and speed, so in this case (situation 2) what are the advantages and disadvantages of
a) using a class with static functions and static members
b) using a namespace with a namespace-level const
c) using a namespace with const inside the (one) function using it
I have tried to find info on this - and found very useful learning information - but nothing to compare using classes with only static methods, versus not using a class at all.