Question: I made the following operator overloading test:

```
#include <iostream>
#include <string>

using namespace std;

class TestClass
{
    string ClassName;

    public:

    TestClass(string Name)
    {
        ClassName = Name;
        cout << ClassName << " constructed." << endl;
    }

    ~TestClass()
    {
        cout << ClassName << " destructed." << endl;
    }

    void operator=(TestClass Other)
    {
        cout << ClassName << " in operator=" << endl;
        cout << "The address of the other class is " << &Other << "." << endl;
    }
};

int main()
{
    TestClass FirstInstance("FirstInstance");
    TestClass SecondInstance("SecondInstance");

    FirstInstance = SecondInstance;
    SecondInstance = FirstInstance;

    return 0;
}

```

The assignment operator behaves as-expected, outputting the address of the other instance.

Now, how would I actually *assign* something from the other instance? For example, something like this:

```
void operator=(TestClass Other)
{
    ClassName = Other.ClassName;
}

```

Answer: 
The code you've shown would do it. No one would consider it to be a particularly good implementation, though.

This conforms to what is expected of an assignment operator:

```
TestClass& operator=(TestClass other)
{
    using std::swap;
    swap(ClassName, other.ClassName);
    // repeat for other member variables;
    return *this;
}

```

BTW, you talk about "other class", but you have only one class, and multiple instances of that class.
You are correct about how to copy the contents from the other class. Simple objects can just be assigned using `operator=`.

However, be wary of cases where `TestClass` contains pointer members -- if you just assign the pointer using `operator=`, then both objects will have pointers pointing to the same memory, which may not be what you want. You may instead need to make sure you allocate some new memory and copy the pointed-to data into it so both objects have their own copy of the data. Remember you also need to properly deallocate the memory already pointed to by the assigned-to object before allocating a new block for the copied data.

By the way, you should probably declare your `operator=` like this:

```
TestClass & operator=(const TestClass & Other)
{
    ClassName = Other.ClassName;
    return *this;
}

```

This is the general convention used when overloading `operator=`. The return statement allows chaining of assignments (like `a = b = c`) and passing the parameter by `const` reference avoids copying `Other` on its way into the function call.