How to ensure a specific class only can create an instance of another class?

Viewed 3625

How can I restrict the instantiation of a class from only within a specific class?

I don't want to restrict it within a single file, so anonymous namespace is not an option for me.

Please note that I want to make the declaration of the to-be-restricted class visible to the entire world, just that only one specific candidate from the entire world can only instantiate it.

How can I achieve this?

2 Answers
Related