title: Templates for setters and getters
body: <p>I am not familiar with templates, but I wonder, if it is possible to use them for setter and getter methods. For example in this situation:</p>
  
  <pre><code>double exmlClass::getA(void) const
  {
      return a_;
  }
  
  
  
  void exmlClass::setA(const double&amp; a)
  {
      a_ = a;
  }
  
  
  
  double exmlClass::getB(void) const
  {
      return b_;
  }
  </code></pre>
  
  <p>As you can see, methods are almost the same, except they refer to another private variables (a_, b_, c_). Is there a more elegant way to write those functions or it is common practice to do like above in such situations? And if its common to use templates, I would appreciate example how you would use them in code above.</p>
  
  <p>Another question I would ask is how should getters and setters be properly declared. Is it good coding style?</p>
  
  <pre><code>double getA(void) const;
  void setA(const double&amp; a);
  
  double getB(void) const;
  void setB(const double&amp; b);
  
  double getC(void) const;
  void setC(const double&amp; c);
  </code></pre>
  
  <p>I mean should getters be always const and setters take as argument reference to an object, rather than copy it, which would be probably a little bit slower?</p>