Hello all,
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 adds 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?
Here is my solution but I don't know whether or not it makes sense.
Use private or protected destructor for the class A and provides a factory function to allocate the object and a function to release the resource (i.e. call destructor)
Thank you