0
Can anyone tell me how to create an object of a private constructor in c++
2 ответов
+ 3
As soon as a constructor is moved under private section of the class, only a friend class or a member function can access it. There are 2 use case of the same that I can think of.
1) in singleton design pattern: where you use a static member function of the class to create/get an instance of the class object.
2) when we want to restrict the object creation to a friend class only.
+ 1
Thankyou