01 // PROJECT AT A GLANCE
C++ POOL — DAY 08
C++What happens when you copy an object that holds allocated memory?
The day deals with the most classic C++ trap: by default, copying an object copies its attributes one by one — memory addresses included. Two objects then end up sharing the same region, which both will try to free. The subject stages droids equipped with a memory, which makes the problem very concrete.
Operator overloading (==, !=, <<, >>, +=, +, the call operator (), and << on std::ostream) and Coplien's canonical form on classes that own their resources: a Droid and its dynamically allocated DroidMemory.
PRIMARYC++
DELIVERYTEAM RECORD
VERIFICATIONgcc/g++
SOURCEINSPECTOR READY
03 // KEY OUTCOMES
- The shallow copy trap, met and solved
- The resource management groundwork that leads to RAII
04 // SOURCE TREE
READING SOURCE…