I have an API I need to loosely emulate as I'm extending it (so no changing conventions), and one of the things I'm having to do is offer setter/getter like access to some private members with a singly name method implemented once for setting and once for getting through signature change.
It looks something like this
class MyClass{
float m_t1;
float m_t2;
public:
const float t1();
const float t2();
void t1(float);
void t2(float);
};
MyClass::MyClass(){
m_t1 = 0.0;
m_t2 = 0.0;
}
const float MyClass::t1(){
return m_t1;
}
const float MyClass::t2(){
return m_t2;
}
void MyClass::t1(float t_val){
m_t1 = t_val;
}
void MyClass::t2(float t_val){
m_t2 = t_val;
}
My question would be, is there a name to this? Maybe as a pattern or as something else.
Though not my first choice if I was doing things from scratch I don't necessarily mind it, but any pointers for me to be able to read about it (caveats, advice, do's and dont's in case it's actually a thing) would be appreciated, just in case it's a pattern with nasty surprises somewhere down the line (in cases a bit more complex than just throwing two floats around).
If anybody wants to share their take on it of course that'd be a bonus, but I'll be happy with just links to further reading.