title: Class Assignment Operators
body: <p>I made the following operator overloading test:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class TestClass
  {
      string ClassName;
  
      public:
  
      TestClass(string Name)
      {
          ClassName = Name;
          cout &lt;&lt; ClassName &lt;&lt; " constructed." &lt;&lt; endl;
      }
  
      ~TestClass()
      {
          cout &lt;&lt; ClassName &lt;&lt; " destructed." &lt;&lt; endl;
      }
  
      void operator=(TestClass Other)
      {
          cout &lt;&lt; ClassName &lt;&lt; " in operator=" &lt;&lt; endl;
          cout &lt;&lt; "The address of the other class is " &lt;&lt; &amp;Other &lt;&lt; "." &lt;&lt; endl;
      }
  };
  
  int main()
  {
      TestClass FirstInstance("FirstInstance");
      TestClass SecondInstance("SecondInstance");
  
      FirstInstance = SecondInstance;
      SecondInstance = FirstInstance;
  
      return 0;
  }
  </code></pre>
  
  <p>The assignment operator behaves as-expected, outputting the address of the other instance.</p>
  
  <p>Now, how would I actually <em>assign</em> something from the other instance?  For example, something like this:</p>
  
  <pre><code>void operator=(TestClass Other)
  {
      ClassName = Other.ClassName;
  }
  </code></pre>