I give the following example to illustrate my question:
class Base
{
public:
virtual void do()=0;
}
class A: public Base
{
public:
void do();
};
class B: public Base
{
public:
void do();
}
class AB: public Base
{
public:
void do()
{
a_.do();
// if not succeed
{
b_.do();
}
}
private:
A a_;
B b_;
}
From the above codes, we can see that class A, B
and AB
come from the same Base class. class AB
, however, needs to invoke both class A
and class B
. Here is my question: what's the potential problem with the class AB
? Are there other alternatives?
Aucun commentaire:
Enregistrer un commentaire