Am learning how to implement c++ move semantic, i need help. The code below are my code so far. It's pouring out error which I can't figure out. Thanks in advance.
You need to declare and define a copy constructor (because that's actually what you are using on line 33).
You need to declare and define a friend ostream & operator << or your lines 34 and 35 aren't going to work.
You have declared both zero-parameter constructor and the destructor ... but you haven't defined either of them.
I'm not convinced that you are moving anything - that would involve reassigning memory - usually dynamically-allocated memory - to another variable. You are, however, doing a lot of copying ... which seems to defeat the object.
> Am learning how to implement c++ move semantic, i need help.
Do nothing at all.
For that particular class (and for most classes that you would be writing), do nothing special;
the implicitly defined (compiler generated) move constructors and move assignment operators would do the right thing.
We need to write code to support move semantics if and only if:
The implicitly-defined special member functions are typically incorrect if the class manages a resource whose handle is an object of non-class type (raw pointer, POSIX file descriptor, etc), whose destructor does nothing and copy constructor/assignment operator performs a "shallow copy" (copy the value of the handle, without duplicating the underlying resource). https://en.cppreference.com/w/cpp/language/rule_of_three
The rule of zero:
Classes that have custom destructors, copy/move constructors or copy/move assignment operators should deal exclusively with ownership (which follows from the Single Responsibility Principle). Other classes should not have custom destructors, copy/move constructors or copy/move assignment operators https://en.cppreference.com/w/cpp/language/rule_of_three#Rule_of_zero