class Player { public: Player(); Player(&Player) const; private: Item * item; } class Item { public: Item(); void virtual Use(); } class Sword : public Item { public: Sword(); void virtual Use(); } Player::Player() { item = new Sword(); } Player::Player(&Player p) { item = new Item(*(p.item)); } The player has a field of type "pointer to the object", which are usually assigned pointers to objects derived from the "object" classes - for example, the "sword". I need to copy the player, then call the Use () method of the item that is stored in the field. After a long sitting in the debugger, there was a feeling that the copy of the player when calling item-> Use () called the method of the parent class (empty).
const? How do you get something to copy, if you yourself prohibit changing the object? - isnullxbh