|
-
Mar 3rd, 2011, 10:31 AM
#1
Thread Starter
Fanatic Member
Re: Why Only 1 Parent in Inheritance?
Yea that diamond is an issue. To be frank, now that inheritance can only be one line, I sort of wonder. What kind of problem need inheritance at all?
-
Mar 3rd, 2011, 07:35 PM
#2
Re: Why Only 1 Parent in Inheritance?
 Originally Posted by teguh123
Yea that diamond is an issue. To be frank, now that inheritance can only be one line, I sort of wonder. What kind of problem need inheritance at all?
You've just got to look at the .NET Framework for your answer. The Component class provides functionality that allows a class to be designed. The Control class extends that by providing UI functionality. The ButtonBase class adds functionality for a control that is intended to be "pressed" like a button. The Button, CheckBox and RadioButton classes all add specific functionality appropriate to their specific use.
Imagine if the Button, CheckBox and RadioButton classes were all built from scratch with no inheritance. There's a whole lot of duplicated code for a start. Also, if you want to change how a button works then you have to do it in all three places.
That's just three classes too. Think about all the other components and controls in the Framework, as well as by third parties, that also inherit the same functionality from the same base classes.
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
|