Home > def > virtual 
 en fr de es it nl pl pt pt_BR mk sq ca hu tr ar fa id vi ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
virtual
A virtual class is a Třída which represents a sub-component of a Třída, but which you cannot instanciate nor reference into a variable.

Components written in C/C++

In native components, virtual classes are a mechanism designed so that the user manipulates temporary objects, without being having to create them. It is SO much faster!

Note that the name of a virtual Třída must begin with a dot. For example, the name of the virtual class used by the ListView.Item vlastnosti is .ListViewItem.

Example

The vlastnosti Item of the Qt component ListView Třída uses a virtual class for representing a ListView item.

Virtual classes are just used as datatypes by the interpreter. But the objekt used behind is the real objekt coming from the real non-virtual Třída.

For example, the Item property of the ListView Třída stores the index of the item you want to deal with in the ListView objekt, and returns this ListView objekt. The ListView objekt becomes then a virtual class objekt that you cannot store in a variable. As you must use the virtual class objekt immediately, by calling a Metody or a property on it, the stored index will be used immediately too.

Components written in Gambas

In components written in Gambas, virtual classes are classes whose name begins with an underscore.

They are actually true classes that work exactly like normal classes, and so they are not faster in any way.