How can I extend a compiler generated copy constructor
问题 I frequently run into the problem, that I must extend a compiler generated copy constructor. Example: class xyz; class C { ... int a, b, c; std::set<int> mySet; xyz *some_private_ptr; }; Assume, that some_private_ptr should only be copied under certain conditions. For other conditions it should be reset to NULL on copy. So I have to write a copy constructor like: C::C(const C &other) : a(other.a), b(other.b), c(other.c), mySet(other.mySet) { if(CanCopy(other.some_private_ptr)) // matches