title: Correct way to return string reference in getter
body: <p>I have a class with a string attribute, and my getters have to return string&amp; values for those attributes.</p>
  
  <p>The only way I managed to do it without getting errors is like this :</p>
  
  <pre><code>inline string&amp; Class::getStringAttribute() const{
      static string dup = stringAttribute;
      return dup;
  }
  </code></pre>
  
  <p>What is the correct way to write a getter returning a string reference of a private string attribute in C++ ?</p>
  
  <p>Doing it like this :</p>
  
  <pre><code>inline string&amp; Class::getStringAttribute() const{
      return stringAttribute;
  }
  </code></pre>
  
  <p>Gets me this error :</p>
  
  <pre><code>error: invalid initialization of reference of type ‘std::string&amp; {aka std::basic_string&lt;char&gt;&amp;}’ from expression of type ‘const string {aka const std::basic_string&lt;char&gt;}’
  </code></pre>