5,321
edits
(→RAII) |
(→RAII) |
||
Line 657: | Line 657: | ||
For instance, the resource for a vector is an allocated amount of memory. Once the vector is destroyed and the destructor called, the resource is released.<br> | For instance, the resource for a vector is an allocated amount of memory. Once the vector is destroyed and the destructor called, the resource is released.<br> | ||
Rf you need any from one of the rules, you need to implement the remainder | |||
Rule of zero | Rule of zero<br> | ||
Do not use a custom deconstructor, copy constructor, or copy assignment. Push all of these operations into the classes of member variables such as <code>std::vector</code> and <code>unique_ptr</code>. This is the best and simplest | Do not use a custom deconstructor, copy constructor, or copy assignment. Push all of these operations into the classes of member variables such as <code>std::vector</code> and <code>unique_ptr</code>. This is the best and simplest case. | ||
[[Wikipedia: Rule of three (C++ programming) | Rule of three]] | [[Wikipedia: Rule of three (C++ programming) | Rule of three]] |