title: Why return string& from a const method won't compile?
body: <p>Given the following code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class A
  {
  private:
      string m_name;
      string m_first;
  public:
      A(): m_first("string") {}
      virtual void print() const {}
      string&amp; getName() const {return m_first;}  // won't compile 
      const string&amp; getLastName() const {return m_name;}  // compile
  };
  
  
  int main()
  {
      A a;
      return 0;
  }
  </code></pre>
  
  <p>Compiler presents : <code>"invalid initialization of reference of type 'std::string&amp;' from expression of type 'const std::string'"</code> 
  Why can't I return "m_first" from getName() ? I thought that the const on the tail of the function states that the function will not change 'this'... but I'm not trying to change this , just return a data member.</p>