![]() ![]() |
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Member
Join Date: Jul 2008
Posts: 1
|
In monotonic inheritance, a subclass can add new properties and/or property values. In non-monotonic inheritance, one can change what’s inherited: either to replace/override (i.e., modify) or to cancel (i.e., delete) an inherited property value.
Which are the languages that support non-monotonic inheritance? How can non-monotonic inheritance be implemented in java? Found that when deletion is required in specialization it can be done in 2 ways. For example, Bird super-class and Penguin child class should not contain the fly() function. The 2 ways are: 1. Create a more “faithful” hierarchy: Create a class bird and 2 children flying-bird and non-flying-bird and derive penguin from non-flying-bird. 2. Redefine “fly” so that it generates a runtime error: void error(const string & msg); class Penguin : public Bird { public: virtual void fly() { error(“Penguins can’t fly!”); }; Are there any other ways of doing this (deleting an inherited attribute)? |
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|