![]() |
Let’s also assume, our German customers of our product with the address object demand to include the federal state as well.
In the present scenario, i. e., that the class „addressFrance“ has been derived from the class „address“, this brings a true problem. If you amend the class „address“ by the desired element „federal state“ the French customers also have got an element „federal state“ although they do not need it, since they have got “their province”.
The solution of this problem is to derive the class „address“ again to a new class „addressGermany“ and to amend the element „federal state“ as well as - if necessary - to adapt and to overwrite of inherited functions.
In this scenario the class „address“ is the common ancestor of the two classes „addressFrance“ and „AddressGermany“. If this scenario is developed further so that the class „Address“ only contains the common properties of all derived classes and it would therefore not be reasonable anymore to instance objects from this class, one speaks of an abstracts class. The only purpose of an abstract class is to declare common properties of ancestors. Normally it is not useful to instance objects from an abstract class.