in reply to a question on namespaces and inheritance

If you need ChildClass2 to use stuff from ChildClass1 with your current design, I think you should reconsider it (the design).

When you inherit Foo from Bar you say that "Foo IS-A Bar" (parrot IS-A bird). So your ChildClass1 IS-A MotherClass and ChildClass2 also IS-A MotherClass.

Now, you say that ChildClass1 and ChildClass2 have some common functionality - and you want to express it by inheriting ChildClass2 from ChildClass1, that is, to say that ChildClass2 IS-A ChildClass1. How about just exporting the common functionality into another class and use multiple-inheritance, if there are really good reasons not to just inherit Child2 from Child1 ?

You're giving an abstract example and it's difficult to help much. Perhaps you can provide us with the real problem at hand ? You may get more specific answers then.

  • Comment on Re: a question on namespaces and inheritance

Replies are listed 'Best First'.
Re^2: a question on namespaces and inheritance
by thcsoft (Monk) on Jun 03, 2005 at 11:43 UTC
    yes, you and all the others blaming me for a bad class design are right. meanwhile i found a way to avoid my difficulties. it has been, as it is so often the case with OOP, a question of dogma and reality. :)
    once again, thank you all for your comments. it's a real pleasure talking with you. :)

    language is a virus from outer space.