Difference between Copy assignment operator vs Move assignment operator

 

Copy Assignment OperatorsMove Assignment Operators
Copy assignment operator takes lvalue reference as an argument.Move assignment operator takes rvalue reference as argument.
Copy assignment operator create a new object from passed object by copying each and every item into a new memory location.Move assignment operator create a new object by using as much memory from passed object.
Since, copy assignment operator use a lot of new memory allocation(for new object). Hence, copy constructors gives bad performance compared to move constructorsSince, move assignment operator use most of memory blocks from passed object. Hence, move constructors gave better performance compared to copy constructors.
Since, copy assignment operator doesn’t make any change to passed object. Hence, passed object can be used after copy operations also.Since, move assignment operator utilizes memory blocks from passed object. Hence, passed object can’t be used after move operations.

For more information related to move assignment operators click here.

Leave a Reply

Your email address will not be published. Required fields are marked *