title: Use of const pointer to class in function
body: <p>I am using std::shared_ptr liberally in my code. I have a few functions that I want to call from MyClass using "this" so have declared these functions as (for example)</p>
  
  <pre><code>int AnotherClass::foo(const MyClass *obj)
  {
  } 
  </code></pre>
  
  <p>I want the const to make it clear obj is not going to get changed since I am passing a raw pointer. 
  However inside foo I have</p>
  
  <pre><code>int AnotherClass::foo(const MyClass *obj)
  {
      int number = obj-&gt;num_points()-1;
  }
  </code></pre>
  
  <p>and my compiler is complaining that "the object has type qualifiers that are not compatible with the member function". num_points is a simple get function declared and defined in the header:</p>
  
  <pre><code>class MyClass {
  public:
    ...
    int num_points(){return _points.size();}
    ...
  private:
    std::vector&lt;MyPoint&gt; _points;
  };
  </code></pre>
  
  <p>What's the best way around this? Obviously I can get rid of the const requirement in foo but I like the rigidity it imposes. 
  Many thanks in advance!</p>