class Base
{
private: bool mEnabled;
public: bool getEnabled() { return mEnabled; }
};
class First : public Base;
{
// ...
};
class Second : public Base
{
Second() {
// I have to check First::mEnabled
}
};
class Manager
{
First obj1;
Second obj2;
};
I have some class manager which handles 2 another classes. And I have to check mEnabled variable in one such object from another. What’s the right way? Would it be right if I’ll make
static bool mEnabled;
static bool getEnabled();
p.s. There would be only 1 objects of this classes.
Instead of static you probably would check for
getEnabledin your class manager:The problem is that you want to get access to another class without any relation between them. So a more top-level class needs to create this relation.