For example, it is sensible for font-family and coloration to be inherited, as that makes it straightforward so that you can set a site-large base font by applying a font-household to the ingredient; you possibly can then override the fonts on individual components where wanted.
For instance, the next C++ code establishes an specific inheritance relationship between classes B and A, the place B is each a subclass and a subtype of A, and can be utilized as an A wherever a B is specified (via a reference, a pointer or the item itself).
With inheritance, all courses-these you write, these from different class libraries that you simply use, and those from the standard utility courses as well-are arranged in a strict hierarchy (see Figure 2.2). Each class has a superclass (the category above it within the hierarchy), and each class can have a number of subclasses (classes under that class within the hierarchy).
By default, your Java classes have entry to solely the courses in (the bottom language bundle inside the java package). Single Inheritance: In single inheritance, a class is allowed to inherit from just one class. You may learn more about class strategies in a while this week.