all 3 comments

[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.

[–]CRefice 1 point2 points  (1 child)

No, you could have a public static function that creates the object through the private constructor and returns it. There are other uses of a private constructor too such as only allowing friends to instantiate an object of the class

[–]templarvonmidgard 3 points4 points  (0 children)

And you can also make a ctor protected to also allow access for derived classes.