S
Simon
Hi,
consider the following
The above code is legal, (as far as I can tell), but it does not look
very 'clean' to me.
Is it bad practice to have a function in the namespace that is not
accessible to the rest of the code?
And is there a better solution than using a static variable, the problem
in my case is that the class constructor is not really slow and, as the
data never changes, it would be foolish to call it over and over simply
to be cosmetically correct.
So, can a namespace have a locally/(private?) declared function?
Is the use of a static variable advisable?
Many thanks
Simon
consider the following
Code:
// header.h
namespace mynamespace{
void someFunction( ... );
}
....
// header.cpp
#include "someclass.h"
namespace mynamespace{
static someclass mSomePrivateClass;
void somePrivateFunction( ... )
{
// use mSomePrivateClass to do some more work
}
void someFunction( ... )
{
...
somePrivateFunction( ... )
...
}
}
The above code is legal, (as far as I can tell), but it does not look
very 'clean' to me.
Is it bad practice to have a function in the namespace that is not
accessible to the rest of the code?
And is there a better solution than using a static variable, the problem
in my case is that the class constructor is not really slow and, as the
data never changes, it would be foolish to call it over and over simply
to be cosmetically correct.
So, can a namespace have a locally/(private?) declared function?
Is the use of a static variable advisable?
Many thanks
Simon