5,321
edits
(→RAII) |
(→RAII) |
||
Line 662: | Line 662: | ||
* Destructor | * Destructor | ||
* Copy constructor | * Copy constructor | ||
* | * Assignment operator | ||
[[Wikipedia: Rule of three (C++ programming)#Rule of five | Rule of five]] | [[Wikipedia: Rule of three (C++ programming)#Rule of five | Rule of five]] | ||
* Move constructor | * Move constructor | ||
* | * Swap function | ||
{{hidden | Example RAII Class | | {{hidden | Example RAII Class | | ||
Line 701: | Line 701: | ||
} | } | ||
// | // assignment operator | ||
dumb_array& operator=(dumb_array other) // (1) | dumb_array& operator=(dumb_array other) // (1) | ||
{ | { | ||
Line 719: | Line 719: | ||
swap(first.mSize, second.mSize); | swap(first.mSize, second.mSize); | ||
swap(first.mArray, second.mArray); | swap(first.mArray, second.mArray); | ||
} | } | ||