I have a piece of code like this
class Base
{
public:
Base(bool _active)
{
active = _active;
}
void Configure();
void Set Active(bool _active);
private:
bool active;
};
class Derived1 : public Base
{
public:
Derived1(bool active):Base(active){}
};
similarly Derived 2 and Derived 3
Now if i call derived1Object.Configure, i need to check how many of the derived1Obj, derived2Obj,derived3Obj is active. Should i add this in the "Base" class like a function say, GetNumberOfActive()?
And If the implementation is like this:
class Imp
{
public:
void Configure()
{
//Code instantiating a particular Derived1/2/3 Object
int GetNumberOfActiveDerivedObj();
baseRef.Configure(int numberOfActiveDerivedClasses);
}
prive:
Derived1 dObj1(true);
Derived2 dObj2(false);
Derived3 dObj3(true);
};
should i calculate the numberOfActive Derived Objects in Imp Class?
THanks