That’s my header:
#ifndef MYCLASSES_H_
#define MYCLASSES_H_
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
namespace mynamespace {
class A
{
class B
{
class C
{
void doStuff(B *pB);
}
static const C SOME_ARRAY[];
static const int SOME_ARRAY_COUNT;
}
}
} //namespace mynamespace
#endif /* MYCLASSES_H_ */
And that’s the CPP:
#include "myclasses.h"
namespace mynamespace {
void A::B::C::doStuff(A::B *pB)
{
/* ... */
}
const A::B::C A::B::SOME_ARRAY[] = {
/*...*/
};
const A::B::SOME_ARRAY_COUNT = ARRAY_SIZE(
} //namespace mynamespace
What shall I do to make the definitions in the .CPP file have shorter names? It’s incredibly cumbersome.
Since B and C are in a private section of class A the world can not see them.
So there is no need to nest them inside A just make them non visible to the outside world.
The easy way to do this is to put them in an anonymous namespace inside the source file.
And that’s the CPP: