| **Navigation:**  [[introduction.htm|Language Reference]] > 2 - Program Source Code Format > Prototype Attributes >====== VIRTUAL (set virtual method) ====== | [[type specify procedure type definition .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[procedure overloading.htm|{{btn_next_n.gif|Next page}}]] | | || ** ** **VIRTUAL** {{blk2blue.jpg|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 object declaration .htm|CLASS]] [[derived prevent function overloading .htm|DERIVED]]