How a designer of a class can ensure that no one outside the class can make a copy of the objects of their class?
Jump to Post
If you means stopping someone doing something like this:
someClass pleaseDoNotCopyMe; someClass IwantToCopy; IwantToCopy = pleaseDoNotCopyMe; // Forbid this someClass anotherCopy(pleaseDoNotCopyMe); // Also forbid this
you can make a private assignment operator and copy constructor
private: someClass (const someClass & theOneToCopy); // no …
All 3 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.