On Sep 3, 2006, at 6:06 AM, Phil M wrote:
On Sep 3, 2006, at 3:57 AM, Carlos M wrote:
Sorry for the ignorance, but what is a Virtual Class and what is
useful for? I searched the net and what I found I didn't
understand it (wikipedia.org does not have anything about it
either). Does it have anything to do with the Singleton Pattern?
An official Virtual class is one that cannot be created in your
application without first subclassing it. It is a class which is
usually mostly complete (like 90%), and so is not fully functional.
I believe the terminology you're looking for is 'pure virtual',
which would correspond to an RB Class Interface, or a C++ class whose
header declares one or more methods as 'virtual' but provides so that
no definition exists, only a declaration. But note that C++ allows
you to make virtual methods that DO have a definition and a
declaration, even though the definition is usually null (only an '{'
and '}').
RB doesn't have this ability, a class either has method
definitions (even if empty) and declarations (Command-M to bring up
the New Method window, which you can also get by double-clicking the
method in the code editor pane on the left), or it has all methods as
declarations only (Class Interface). You can't make an RB class that
has a mix of pure virtual methods and regular methods (unless this is
a new feature of RB2006r3 that I don't know about... :) )
One purpose I am using it for is to simplify the subclasses so that
they do not have quite as much code.
I have the XBarBase class which is my virtual class. Then I have
XBarButton as a subclass of XBarBase, and I have a second class
called XBarSpacer which is also a subclass of XBarBase. Any
XBarButton and XBarSpacer is also a XBarBase, but since XBarBase
only has limited drawing features it is not a useful class by itself.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>