Gambas/inheritance

Documentation
To specify that your class should inherit from the ParentClass class, insert this at the beginning of the class file: INHERITS ParentClass Note that if you are inheriting from a virtual class, you need to leave off the period (e.g. to inherit from .ListViewItem, use "INHERITS ListViewItem").

What is inherited?
The class inherits from its parent every method, property, constant and event.

Which class can be a parent class?
You can inherit any class, even a native one!

For example, you can create a custom MyListBox class that inherits ListBox but allows association a tag with each list item.

Note that you can't use INHERITS in a form class file, because forms already inherits the Form class.

Inheritance and constructor
Unlike many (or most) object-oriented languages, in Gambas each class in the inheritance hierarchy consumes the parameters passed to the constructor.

Let's suppose we have the following inheritance tree: So NEW MyListBox will take two parameters. The first will be sent to MyListBox._new, the second to ListBox._new. But the ListBox._new will be called first. This way, you are sure that the ListBox control exists when you are in MyListBox._new.
 * MyListBox ---inherits--> ListBox ---inherits---> Control
 * Control._new does not exist.
 * ListBox._new takes one parameter: the parent control.
 * MyListBox._new takes one parameter: a name - It is just an example.

You then create a MyListBox control this way:
 * aMyListBox = NEW MyListBox ( "Name", aContainer )

Errors

 * "Bad use of virtual class"