What is The Rule of Three?
@lebyy▲ 0 net votes
Problem: What does copying an object mean? What are the copy constructor and the copy assignment operator ? When do I need to declare them myself? How can I prevent my objects from being copied? Fix (from the top answer): Introduction C++ treats variables of user-defined types with value semantics . This means that objects are implicitly copied in various contexts, and we should understand what "copying an object" actually means. Let us consider a simple example: class person { std::string name; int age; public: person(const…