Hi boost users,
A friend of mine wants to expose properties in his classes in the form
properties exist in other languages such as Delphi or VB or C#. I don't
agree with the idea since get and set methods are just fine for me but I
thought I would send this question out and see if any of you have a
recommendation. The idea would be the following:
class CButton
{
public:
void SetColor(const int & nColor) { m_nColor = nColor; }
const int & GetColor() const { return m_nColor; }
private:
int m_nColor;
};
So of course we can set and retrieve the color of a CButton instance using
the get and set methods in the way:
CButton button;
button.SetColor(5);
int nColor = button.GetColor();
However what my friend wants to do is to expose methods so we can do:
button.color = 5;
int nColor = button.color;
...and the get and set method would be called internally. He already has a
solution for this problem using a template class property