title: Const reference field as readonly property in C++ class
body: <p>Is it good to use a const reference field as a readonly getter in C++ classes?</p>
  
  <p>I mean, does this code meet good practices?</p>
  
  <pre><code>class check{
  private:
      int _x;
  public:
      const int&amp; x = _x;
      void setX(int v){
          _x = v;
      }
  };
  </code></pre>
  
  <p>It is working very much like C# properties, IMHO, and very easy and clean in class usage code:</p>
  
  <pre><code>  check s;
    int i;
    std::cin &gt;&gt; i;
    s.setX(i);
    std::cout &lt;&lt; s.x &lt;&lt; '\n';
    s.setX(7);
    // s.x = i; // Error
    std::cout&lt;&lt;s.x&lt;&lt;'\n';
  </code></pre>