#include <iostream>

using namespace std;

class C 
{
  public:
    C(std::string someName) : name(someName) {}

    void swap(C& other)
    {
        name.swap(other.name);
        cout << "swap, other = " << other.name << "(" << &other << ")" << endl;
    }

    C(C&& other) // конструктор копирования
    {
        this->swap(other);
    }

    C& operator=(C other) // оператор присваивания
    {                     // передача параметра по значению важна!
        swap(other);      // обмен с временной копией
        return *this;
    }

    std::string name;
};

int main(int argc, char* argv[])
{
    C c1("c1");
    C c2(c1);
    cout << "c1 -> " << c1.name << endl;
    cout << "c2 -> " << c2.name << endl;
}