Hello,
I am using a singleton pattern, which works fine. But when I decided to have a singleton of a nested class that is privately declared.
class A : public CSingletonTmpl<A>
{
class B : public CSingletonTmpl<B>
{
};
};
A* CSingletonTmpl<A>::s_Singleton = NULL;
A::B* CSingletonTmpl<A::B>::s_Singleton = NULL;
The last line causes a compile time error: 'A::B' : cannot access private class declared in class 'A'.
I understand that class B is private and if I do not want to make it public, what are my options?
I do know that if I do not use CSingletonTmpl, but declare s_Singleton directly as a member of B, then A::B::s_Singleton can be instantiated. This seems strange to me. Why should not I be able to access s_Singleton if it is in the publicly derived class for B?
Thanks.