C++ using 'this' as a parameter
<p>I have a class which looks approximately like this:</p>

<pre><code>class MeshClass
{
public:
    Anchor getAnchorPoint(x, y)
    {
      return Anchor( this, x, y );
    }
private:
    points[x*y];
}
</code></pre>

<p>I want to make another class which represents an "Anchor" point which can get access to the Mesh and modify the point, like this:</p>

<pre><code>class Anchor
{
public:
    Anchor(&amp;MeshClass, x, y)
    moveAnchor(x, y);
}
</code></pre>

<p>The problem is when I try to make the <code>Anchor</code> in the <code>MeshClass::getAnchorPoint</code> method, something like <code>return Anchor(this, x, y)</code> but because <code>this</code> is const I can't.  As a workaround until I get this figured out I have Anchor accepting a reference to the point and moveAnchor moves the point directly.</p>

<p><strong>Edit:</strong> The problem was most likely something dumb I was doing with trying to use a Reference.  I changed to using a pointer like I normally would and I can pass in <code>this</code> with no complaints from the compiler.  I'm almost certain I was getting an error related to this being const, but I can't recreate it so I must just be out of my mind.</p>
