J
jeffc
Don't know what to put in the subject, because if this has a name I don't
know it.
You are modifying an existing application. You are not allowed to make more
than minor changes. For example, there is class B, which is instantiated by
class A. You wish to modify B, so you derive B2. You are allowed to make a
minor change such as replacing the raw "new" in class A with a "create"
function. You derive A2 from A and override this function, and instantiate
B2 instead of B.
There are multiple classes such as A that instantiate a B. However, you
come across 2 of them that instantiate a B3 instead of a B (B3 derives from
B). Now you have a situation where you need to alter both the behavior of B
and B3. You have to create B4 to derive from B3. But you put the exact
same behavior in B4 as you did in B2, which you want to avoid for obvious
reasons.
B
|\
| \
| \
| \
B3 B2
|
|
B4
In some cases you'll want to create a B4, and in some cases a B2. Is there
any way to get your class "inserted" into the hierarchy? You are not
allowed to alter the class the B3 derives from. (By the way, multiple
inheritance is not supported.)
know it.
You are modifying an existing application. You are not allowed to make more
than minor changes. For example, there is class B, which is instantiated by
class A. You wish to modify B, so you derive B2. You are allowed to make a
minor change such as replacing the raw "new" in class A with a "create"
function. You derive A2 from A and override this function, and instantiate
B2 instead of B.
There are multiple classes such as A that instantiate a B. However, you
come across 2 of them that instantiate a B3 instead of a B (B3 derives from
B). Now you have a situation where you need to alter both the behavior of B
and B3. You have to create B4 to derive from B3. But you put the exact
same behavior in B4 as you did in B2, which you want to avoid for obvious
reasons.
B
|\
| \
| \
| \
B3 B2
|
|
B4
In some cases you'll want to create a B4, and in some cases a B2. Is there
any way to get your class "inserted" into the hierarchy? You are not
allowed to alter the class the B3 derives from. (By the way, multiple
inheritance is not supported.)