Jump to content

C++: Difference between revisions

Line 657: Line 657:
In general, each RAII object should have all of the following:
In general, each RAII object should have all of the following:
* Constructor acquiring resources
* Constructor acquiring resources
Rule of three:
* Copy Constructor
* Copy Constructor
* Assignment operator
* Assignment operator
* Destructor releasing resources
* Destructor releasing resources
Rule of five:
* Swap function (for <code>std::swap</code>)
* Swap function (for <code>std::swap</code>)
* Move constructor (since C++11, for <code>std::move</code>)
* Move constructor (since C++11, for <code>std::move</code>)