Show TOC

 Defining Relationships Between Object TypesLocate this document in the navigation structure

Use

You can define the following relationships between two object classes:

  • Inheritance between two classes
  • Extending the functions of a class by implementing interfaces (a relationship between classes and interfaces)
  • Compound interfaces (a relationship between interfaces)
  • Friends relationship (a relationship between a class and its users).
Features
  • Inheritance is a relationship between classes. It allows you to derive a new class from the definition of an existing class. The new class is called a subclass, the existing class is its superclass. Inheritance is used to create a subclass that is more specialized than its superclass. You can add new components to a subclass and also redefine the methods it inherits. The result of inheritance is a class hierarchy. The Class Builder allows you to create a class hierarchy in a simple way: you can create a subclass for any class that is not defined as final, and can also define a direct superclass for a class that was itself not derived.
  • Interfaces allow you to extend a class definition. When a class implements an interface, all the components defined in the interface appear as class components. You can access the components defined in the interface either by class or by interface reference.Interfaces allow you to work with several different classes in a uniform way. The actual implementation of the interface components takes place in the classes. Consequently, interfaces provide a way of separating the definition and implementation of components.
  • Interfaces can contain attributes, methods, and events, but also other interfaces. Classes that implement a compound interface must also implement all of its components. Compound interfaces are a specialization of their component interfaces.
  • In a friends relationship a class gives to predefined users access to its PROTECTED and PRIVATE components.