title: Getter and setter, pointers or references, and good syntax to use in c++?
body: <p>I would like to know a good syntax for C++ getters and setters.</p>
  
  <pre><code>private:
  YourClass *pMember;
  </code></pre>
  
  <p>the setter is easy I guess:</p>
  
  <pre><code>void Member(YourClass *value){
    this-&gt;pMember = value; // forget about deleting etc
  }
  </code></pre>
  
  <p>and the getter?
  should I use references or const pointers?</p>
  
  <p>example:</p>
  
  <pre><code>YourClass &amp;Member(){
     return *this-&gt;pMember;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>YourClass *Member() const{
    return this-&gt;member;
  }
  </code></pre>
  
  <p>whats the difference between them?</p>
  
  <p>Thanks,</p>
  
  <p>Joe</p>
  
  <p>EDIT:</p>
  
  <p>sorry, I will edit my question... I know about references and pointers, I was asking about references and const pointers, as getters, what would be the difference between them in my code, like in hte future, what shoud I expect to lose if I go a way or another...</p>
  
  <p>so I guess I will use const pointers instead of references</p>
  
  <p>const pointers can't be delete or setted, right?</p>