Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String& operator=(String&& other) noexcept
- { // Not constructing new object like in the move constructor above, we're moving another object into this current object
- // Meaning we need to overwrite the current object
- printf("Moved!\n");
- if (this != &other) // Making sure we can't move the current object into itself. AKA same object.
- {
- delete[] m_Data; // Have to add this because we're about to move another object into ourselves and the old data has to be deleted
- m_Size = other.m_Size;
- m_Data = other.m_Data;
- other.m_Size = 0;
- other.m_Data = nullptr;
- }
- return *this; // reference to current object
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement