title: Returning non-const reference from a const member function
body: <p>Why does returning the reference to a pointed-to member variable work, but not the other?  I know that a <code>const</code> member function should only return <code>const</code> references, but why does that not seem true for pointers?</p>
  
  <pre><code>class MyClass
  {
    private:
      int * a;
      int b;
    public:
      MyClass() { a = new int; }
      ~MyClass() { delete a; }
  
      int &amp; geta(void) const { return *a; } // good?
      int &amp; getb(void) const { return b; }  // obviously bad
  };
  
  int main(void)
  {
    MyClass m;
  
    m.geta() = 5;  //works????
    m.getb() = 7;  //doesn't compile
  
    return 0;
  }
  </code></pre>