If I don't want to allow anyone to create an instance of my class except for my static functions (I think this is called singleton/factory?), is it enough to make the default constructor private, or do I also need to explicitly define and make private a copy constructor and assignment operator?
Making the constuctor private is for the factory method pattern. The singleton pattern needs a factory method.
boost has noncopyable if you don't want your class to be copied, but as James McNellis already commented: decide whether users should be able to copy the class. Because raw pointers and the inherent memory management should not have a place in classes anymore, the question of having classes copied is mostly for classes that use resources or possibly large containers.
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