My guess is that this might be useful for a class containing a list of itself - then it can copy instances inside. This is really only useful for a class that is both an element and a container:
class MyItems { private: List list; public: void AddItems(MyItems* items) { MyItems* added = new MyItems(items); list.Add(added); } };
Another thought is to allow cloning in circumstances controlled by the class. This can be useful when copying may make sense, but only under certain conditions or permissions:
class MyClass { private: public: MyClass* clone() { if (canClone) { MyClass* cloned = new MyClass(this); return cloned; } else { return NULL; } } };
Eli iser
source share