Creating Subclasses 

Use

Inheritance allows you to derive classes from other classes. The new class contains a greater range of more specific functions than its superclass. You can do this by adding new components to the subclass or redefining methods inherited from the superclass.

Procedure

To create a new direct subclass from an existing class in the class editor:

  1. Choose Basic data for the current class.
  2. Choose Subclass.
  3. The Create Class dialog box appears.

  4. Enter the following details for the subclass definition:
  5. - Class

    Name of the subclass you want to derive.

    - Inherits from

    Enter any global class that is not defined as final.

    - Description

    Enter a descriptive short text for the subclass.

    - Instantiation

    The default setting for all classes is public. This means that all users can instantiate the class using CREATE OBJECT. If you specify protected, only inherited classes or the class itself can instantiate the class. If you specify private, the class can only be instantiated by itself.
    These options allow you to restrict the instantiation of the class. For example, it provides the basis for managing persistent objects, where you have to ensure that objects are unique.

    - Inheritance

    If you specify Abstract, you can define an abstract class. Abstract classes cannot be instantiated, but you can use them as a template for further subclasses. You can only access an abstract class using its static components or subclasses.
    The Final option defines a final class. This class forms the end of the inheritance hierarchy, since final classes cannot have subclasses.
    If you define a class as both abstract and final, you can only access its static components.

    - Only modeled

    If you select this option, the subclass is not included in the class pool. You cannot access the class at runtime.

  6. Choose Save.
  7. The Create Object Directory Entry dialog box appears.

  8. Enter the development class.
  9. Choose Save.

Result

You have now created a direct subclass for a class. The subclass inherits all components from the public and protected sections of the superclass, apart from the constructor methods. The interfaces implemented in the superclass are also implemented and visible in the subclass. You can display the inherited components of the subclass by selecting With inherited.
You can now specialize your class. For further information, refer to
Extending Subclasses.