You have almost certainly encountered certain situations, where a class owns some resources that must not be copied for technical reasons:
class descriptor_owner {
void* descriptor_;
public:
explicit descriptor_owner(const char* params);
~descriptor_owner() {
system_api_free_descriptor(descriptor_);
}
};
The C++ compiler in the preceding example generates a copy constructor and an assignment operator, so the potential user of the descriptor_owner class will be able to create the following awful things:
void i_am_bad() {
descriptor_owner d1("O_o");
descriptor_owner d2("^_^");
// Descriptor of d2 was not correctly freed
d2 = d1;
// destructor of d2 will free the descriptor
// destructor of d1 will try to free already freed descriptor
}