The revised example
class Whole {public: // ...Lots omitted... Whole& operator=(const Whole& rhs); private: std::auto_ptr<PartOne> p1; std::auto_ptr<PartTwo> p2;};
Notes:
In order to conform to the rule regarding ownership of multiple objects we’ll delegate the responsibility of resource ownership to a couple of helper classes.
[I’m using the std::auto_ptr<> template here because it is standard, not because it is the ideal choice.]