title: C++ getters/setters coding style
body: <p>I have been programming in C# for a while and now I want to brush up on my C++ skills. </p>
  
  <p>Having the class:</p>
  
  <pre><code>class Foo
  {
      const std::string&amp; name_;
      ...
  };
  </code></pre>
  
  <p>What would be the best approach (I only want to allow read access to the name_ field):</p>
  
  <ul>
  <li>use a getter method: <code>inline const std::string&amp; name() const { return name_; }</code></li>
  <li>make the field public since it's a constant</li>
  </ul>
  
  <p>Thanks.</p>