The question is pretty self explanatory. If you are required to create one of them does that imply you have to create the second one too?
The usual need to write these is, as mentioned in the comments above.
However, one can imagine other needs that fit your question. For example, if you want to count the number of objects in your program. A copy constructor will need to increment a counter, whereas an assignment does not change the number of objects, and therefore the default will do.
When it does not make sense to assign-to an object of a certain type, you do not write/delete the assingnment op. It still might make sense to have a copy ctor though.
A technical example is a class with reference members. Copy construction is possible, copy assignment not really as you cannot change what the ref members point to.
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