C++ operator= overload works selectively
<p>I appear to have an assignment operator that works circumstatially.
I have a Vector2 class which contains two float's, x and y.
Here is the operator= method:</p>

<pre><code>Vector2 Vector2::operator=(const Vector2 &amp;right)
{
    Vector2 result;
    result.x = right.x;
    result.y = right.y;
    return result;
}
</code></pre>

<p>Within an onMove method for an entity I have:</p>

<pre><code>Vector2 newPosition = position + (speed * getSpeedFactor());

if (posValid(newPosition))
{
    position.x = newPosition.x;
    position.y = newPosition.y;
    //position = newPosition;
}
</code></pre>

<p>Where speedFactor depends on framerate and posValid is a check for whether a point is in a wall or something. position and speed are also Vector2's.
The first assignment:</p>

<pre><code>Vector2 newPosition = position + (speed * getSpeedFactor());
</code></pre>

<p>works, and with the code as is I get the expected/intended behaviour, however</p>

<pre><code>position = newPosition;
</code></pre>

<p>has no effect, whether on it's own or before or after the .x &amp; .y assignments.</p>
