Move Assignment Operator explained with simple example
In C++11 (Introduction to C++11) , move assignment operator are added which can improve any code’s performance drastically. Typically a move assignment operator is same as copy/move constructor but before reusing the memory blocks from passed object, it releases all the memory which is owned by this object. Since, memory reallocation is avoided in case of move assignment operators. Thus it gives better performance.
However while implementing move assignment operators we need to take care of one important point to ensure that the original object can be correctly destroyed.
Let’s take an example to see how this memory reallocation is avoided in case of move assignment.