Content deleted Content added
Monospace |
|||
(33 intermediate revisions by 25 users not shown) | |||
Line 1:
{{Short description|Operator used in C++}}
In the [[C++|C++ programming language]], the '''move assignment operator'''
If the move assignment operator is not explicitly defined,
== Overloading move assignment operator ==
To overload the move assignment operator, the signature of the function must be
T& operator=(T&& data)
</syntaxhighlight>To successfully overload the move assignment operator, the following conditions must be met:
Line 12 ⟶ 11:
* The current object's data is de-allocated.
* The object that is being moved from must have its data marked as [[nullptr]] (or something to signify the move)
* The operator
class
public:▼
▲public:
// If we're not trying to move the object into itself...
delete[] this->data_; // Free this string's original data.
other.data_ =
}
private:
};
</syntaxhighlight
==References==▼
<references />▼
{{C++ programming language}}
▲ String& operator=(String&& otherString) {
▲ return *this;
[[Category:C++]]
▲ char* text;
[[Category:Operators (programming)]]
[[Category:Assignment operations]]
{{compu-prog-stub}}
▲==References==
▲<references />
|