you have a class A, where you set ctor to be private, so a client can't call "A a;" to create obj on stack. But someday another developer add a new ctor: "A(int)" and try to call "A a(1);" inside main(). So this will create a obj on stack. How do you prevent that?
If, as you imply, your class gets edited, then there is nothing you can do that can't be "edited away" -- your having only a private ctor was perfectly good protection, but it got edited away by that other developer. Just document very clearly that the class must never be edited to have public ctors, and, as a comment said, don't hire people who'd trample over such requirements!-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With