User Tools

Site Tools


virtual_set_virtual_method_.htm
Navigation:  Language Reference > 2 - Program Source Code Format > Prototype Attributes >====== VIRTUAL (set virtual method) ====== Previous pageReturn to chapter overviewNext page

 

VIRTUAL

blk2blue.jpg

The VIRTUAL attribute specifies that the PROCEDURE on whose prototype it is placed is a virtual method of the CLASS containing the prototype. This allows methods in a parent CLASS to access methods in a derived CLASS. The VIRTUAL attribute must be placed on both the method's parent class prototype and the derived class's prototype.

Example:

OneClass  CLASS                         !Base class

BaseProc   PROCEDURE(REAL Parm)         !Non-virtual method

Proc       PROCEDURE(REAL Parm),VIRTUAL !Declare a virtual method

         END

TwoClass  CLASS(OneClass)               !Derived class of OneClass

Proc       PROCEDURE(REAL Parm),VIRTUAL !Declare a virtual method

         END

ClassThree OneClass         !Another Instance of a OneClass object

ClassFour  TwoClass         !Another Instance of a TwoClass object

CODE

OneClass.BaseProc(1)       !BaseProc calls OneClass.Proc

TwoClass.BaseProc(2)       !BaseProc calls TwoClass.Proc

ClassThree.BaseProc(3)     !BaseProc calls OneClass.Proc

ClassFour.BaseProc(4)      !BaseProc calls TwoClass.Proc

OneClass.BaseProc  PROCEDURE(REAL Parm)

CODE

SELF.Proc(Parm)            !Calls virtual method, either OneClass.Proc

                           ! TwoClass.Proc, depending on which

                           ! class instance is executing

See Also:

CLASS

DERIVED

virtual_set_virtual_method_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1