Context: My C++ experience is about 3/10, so bear with me.
I'm curious to know if it's possible to attach a read callback function to a C++ object member, so that when I assign:
var = object.member;
this calls a callback, which updates member before returning it. I can achieve the same end by
...
var = object.GetMemberVal();
...
int FooClass::GetMemberVal()
{
// update member value
return this->member;
}
But val = object.member; (no parens) is a bit cleaner and seems closer to the spirit of object-orientedness... I think.
I think member function as callback may be related, but I'm not totally following.
Whether this is a good idea or not may be up for debate, I'm just interested to know if it's possible.