New course! Every coder should learn Generative AI!
Try a free lesson+ 6
Yes. It's valid. Sometimes it is used to implement a singleton design pattern.
In singleton, costructor is private and you don't allow several objects of the class. Just only one object accessed via some function, not the constructor.
Check this example. It's in java but it's the same idea:
https://code.sololearn.com/ch966glxnCY5/?ref=app