Creating an assignment (=) operator for class in C++
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4421706/operator-overloading">Operator overloading</a>  </p>
</blockquote>



<p><strong>EDIT 2</strong></p>

<p>I was using insert(...) incorrectly, I didn't actually need a '=' operator.  Sorry to waste peoples' time.  I have voted to close.. 2 votes remain.  Please vote.</p>

<p><strong>EDIT</strong></p>

<p>The reason I want an '=' operator is so I can use the insert(...) function on a vector of Derivation objects.  At the moment my compiler says:</p>

<p><code>/usr/include/c++/4.2.1/bits/stl_algobase.h:283: error: no match for 'operator=' in '* __result = * __first'</code></p>

<p>I have created '==' and '&lt;' operators for my own classes before but I'm struggling to create an '=' operator.  My class looks like this (ignore the silly variable names):</p>

<pre><code>class Derivation {
public:
    string                  rc; 
    ImplementationChoice    Y; 
    vector&lt;Derivation&gt;      X;
    vector&lt;string&gt;          D;       
    vector&lt;string&gt;          C;       
    vector&lt;Player&gt;          P, O;   
    vector&lt;Attack&gt;          B;   

    // various functions
    // ...
};
</code></pre>

<p>and I want to know what I need to put in</p>

<pre><code>// What do '=' return?  An object of the class right?
Derivation&amp; operator=(const Derivation &amp;d) const {
    // something....
}
</code></pre>

<p>Many thanks.</p>
