You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, in the Registry of Singletons example, it is still possible to create instances of MySingleton using its default constructor. If we try to avoid that by making the MySingleton() constructor protected instead of public, then the line
static MySingleton theSingleton;
in MySingleton.cpp gives an error at compile time:
error C2248: 'MySingleton::MySingleton': cannot access protected member declared in class 'MySingleton'
See also the TODO in Creational_Patterns/Singleton/registry_of_singletons/main.cpp.
The text was updated successfully, but these errors were encountered:
Apparently, in the Registry of Singletons example, it is still possible to create instances of
MySingleton
using its default constructor. If we try to avoid that by making theMySingleton()
constructor protected instead of public, then the linein
MySingleton.cpp
gives an error at compile time:See also the
TODO
inCreational_Patterns/Singleton/registry_of_singletons/main.cpp
.The text was updated successfully, but these errors were encountered: