I refer to this question: What is the copy-and-swap idiom?
Effectively, the above answer leads to the following implementation:
class MyClass { publi
for mebest do it like this in C++11:
class MyClass { public: MyClass(MyString&& pStr) : str(pStr)) { // call MyString(MyString&& pStr) } MyClass(const MyString& pStr) : str(pStr)) { // call MyString(const MyString& pStr) } private: MyString const str; // Still const! };