<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - virtual
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../def+en">Up</a>&nbsp;
<a href="utf8+en">Previous</a>&nbsp;
<a href="../doc+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
virtual
</h1>
A virtual class is a class which represents a sub-component of a class, but which you cannot instanciate nor reference into a variable.
<p>
For example, the property <a href="../comp/gb.qt/listview/item+en">Item</a> of the Qt component <a href="../comp/gb.qt/listview+en">ListView</a> class uses a virtual class for representing a <a href="../comp/gb.qt/listview+en">ListView</a> item.
<p>
Virtual classes are just used as datatypes by the interpreter. But the object used behind is the real object coming from the real non-virtual class.
<p>
For example, the <a href="../comp/gb.qt/listview/item+en">Item</a> property of the <a href="../comp/gb.qt/listview+en">ListView</a> class stores the index of the item you want to deal with in the <a href="../comp/gb.qt/listview+en">ListView</a> object, and returns this <a href="../comp/gb.qt/listview+en">ListView</a> object. The <a href="../comp/gb.qt/listview+en">ListView</a> object becomes then a virtual class object that you cannot store in a variable. As you must use the virtual class object immediately, by calling a method or a property on it, the stored index will be used immediately too.
<p>
This mechanism has been designed so that the user manipulates temporary objects, without being compelled to create them. It is <b>SO</b> much faster!
<p>
Note that the name of a virtual class must begin with a dot. For example, the name of the virtual class used by the <a href="../comp/gb.qt/listview+en">ListView</a>.<a href="../comp/gb.qt/listview/item+en">Item</a> property is <a href="../comp/gb.qt/_listviewitem+en">.ListViewItem</a>.

</div>
</body>
</html>

