How a designer of a class can ensure that no one outside the class can make a copy of the objects of their class?
Shahrukh017
0
Newbie Poster
Recommended Answers
Jump to PostIf 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
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
phfilly
26
Junior Poster
Moschops
683
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.