I have a member variable, enabled_mwhose value depends on a number of variables. Since these invariants must be supported by the class, I want it to be private:
class foo_t
{
public:
void set_this(...);
void set_that(...);
void set_the_other_thing(...);
bool is_enabled() const { return enabled_m; }
private:
bool enabled_m;
};
Which works, but actually I want the user to foo_tgo through the class to change enabled_m. If the user just wants to read enabled_m, this should be a valid operation:
bool my_enabled = foo.enabled_m;
foo.enabled_m = my_enabled;
Is there a way to do enabled_m publicfor operations constand privatefor operations without const, without requiring the user to go through access procedures?
source
share