When you declare a move constructor the implicitly defined copy constructor will be deleted.
There is no reason why you should define a move constructor for MyObj because it will do the same as the copy constructor anyway.
Thanks,I am learning C++ now ,and it was explained that if our object is big is better to use move instead of copy.
Can you explaine why implicitly defined copy constructor will be deleted
Can you explaine why implicitly defined copy constructor will be deleted
Because the standard says so
C++11 ยง12.8/7
If the class definition declares a move constructor or move assignment operator, the implicitly declared copy constructor is defined as deleted;
If there is a reason do define a move constructor the default copy constructor will almost certainly don't work. I guess that is the reason for this rule.
You should get that reference to local var temp returned(enabled by default whether or not
you have the move contructor - because the operator+ function does return a reference to a local variable...
Lio wrote:
Thanks,I am learning C++ now ,and it was explained that if our object is big is better to use move instead of copy.
Who said that - or what book did you read that from??
That is totally incorrect!