|
-
Mar 3rd, 2011, 07:53 PM
#1
Re: Why Only 1 Parent in Inheritance?
Remeber one of the OO design principles: Favour composition over inheritance.
SH and jmclongname both describe situations that could also be solved with composition. First off, take your "base class" and generate an interface that describes the concept the base class is describing. Next, take your derived class, and don't inherit from the base, but implement the interface instead. Have your "derived" class hold a reference to the "base" class. Implement the interface by delegating all calls to the "base" class instance you have a reference to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|