title: C++ and const - accessing a member function of a const reference
body: <p>I have this snippet of code here. The intention is to make a copy of initialData. Since I am not modifying initialData in any way, I figure that I should pass it as a const reference. However, I keep getting this message when compiling.</p>
  
  <blockquote>
    <p>.\src\Scene\SceneAnimationData.cpp(23)
    : error C2662:
    'SceneTrackerData::getRect' : cannot
    convert 'this' pointer from 'const
    SceneTrackerData' to 'SceneTrackerData
    &amp;'</p>
  </blockquote>
  
  <pre><code>#include "SceneTrackerData.h"
  
  void SceneAnimationData::SetupData(const SceneTrackerData &amp;initialData)
  {
      // getRect(), points() and links() all return const pointers
      CloneRect(initialData.getRect());
      ClonePoints(initialData.points()-&gt;values());
      CloneLinks(initialData.links()-&gt;values());
  }
  
  void SceneAnimationData::CloneRect(const QGraphicsRectItem * initialRect) 
  {
      if (initialRect != NULL)
      {
          QPointF position = initialRect-&gt;scenePos();
          QRectF rect = initialRect-&gt;rect();
  
          initialRect = new QGraphicsRectItem(rect);
          initialRect-&gt;setPos(position);
      }
  }
  
  void SceneAnimationData::CloneLinks(const QList&lt;QGraphicsLineItem*&gt; links) 
  {
      links_ = new QList&lt;QGraphicsLineItem*&gt;(*links);
  }
  
  void SceneAnimationData::ClonePoints(const QList&lt;QGraphicsEllipseItem*&gt; points) 
  {
      points_ = new QList&lt;QGraphicsEllipseItem*&gt;(*points);
  }
  </code></pre>