#include <iostream>
#include <string>
using namespace std;
class Example6 {
string* ptr;
public:
Example6 (const string& str) : ptr(new string(str)) {}
~Example6 () {delete ptr;}
Example6 (Example6&& x) : ptr(x.ptr) {x.ptr=nullptr;}
Example6& operator= (Example6&& x) {
delete ptr;
ptr = x.ptr;
x.ptr=nullptr;
return *this;
}
const string& content() const {return *ptr;}
Example6 operator+(const Example6& rhs) {
return Example6(content()+rhs.content());
}
};
int main () {
Example6 foo ("Exam");
Example6 bar = Example6("ple");
foo = foo + bar;
cout << "foo's content: " << foo.content() << '\n';
return 0;
}