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 traditional canonical form of the assignment operator looks like this: 

```
TestClass& operator=(const TestClass& Other);

```

(you don't want to invoke the copy constructor for assignment, too) and it returns a reference to `*this`. 

A naive implementation would assign each data member individually: 

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

```

(Note that this is exactly what the compiler-generated assignment operator would do, so it's pretty useless to overload it. I take it that this is for exercising, though.) 

A better approach would be to employ the ***[Copy-And-Swap idiom](https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom/)***. (If you find GMan's answer too overwhelming, try [mine](https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom/3279616#3279616), which is less exhaustive. `:)`) Note that C&S employs the copy constructor and destructor to do assignment and therefore requires the object to be passed per copy, as you had in your question: 

```
TestClass& operator=(TestClass Other)

```
Traditionnaly the assignment operator and the copy constructor are defined passing a const reference, and not with a copy by value mechanism.

```
class TestClass 
{
public:
    //... 
    TestClass& operator=(const TestClass& Other)
    {
        m_ClassName= Other.m_ClassName;
        return *this;
    }
private:
    std::string m_ClassName;
 }

```

EDIT: I corrected because I had put code that didnt return the TestClass& (c.f. @sbi 's answer)