Difference between Copy constructor vs Move constructor

 

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

For more information related to Move constructors click here

Leave a Reply

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