Jump to content

C++: Difference between revisions

22 bytes removed ,  15 April
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>


The rule for RAII is if you need any from one of the rules, you need to implement the remainder
Rf you need any from one of the rules, you need to implement the remainder


Rule of zero:<br>
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 cast.
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]]