User Tools

Site Tools


protected_set_procedure_private_to_a_class_or_derived_class_.htm
Navigation:  Language Reference > 2 - Program Source Code Format > Prototype Attributes >====== PROTECTED (set procedure private to a CLASS or derived CLASS) ====== Previous pageReturn to chapter overviewNext page

 

PROTECTED

blk2blue.jpg

The PROTECTED attribute specifies that the PROCEDURE on whose prototype it is placed is visible only to the PROCEDUREs declared within the same CLASS structure (the other methods of that CLASS) and the methods of any CLASS derived from the CLASS. This encapsulates the PROCEDURE from being called from any code external to the CLASS within which it is prototyped or subsequently derived CLASSes.

Example:

OneClass  CLASS,MODULE('OneClass.CLW'),TYPE

BaseProc   PROCEDURE(REAL Parm)                      !Public method

Proc       PROCEDURE(REAL Parm),PROTECTED            !Declare a protected method

         END

TwoClass  OneClass                                   !Instance of OneClass

ThreeClass CLASS(OneClass),MODULE('ThreeClass.CLW')  !Derived from OneClass

ThreeProc   PROCEDURE(REAL Parm)                     !Declare a Public method

          END

CODE

TwoClass.BaseProc(1)                                !Legal call to BaseProc

TwoClass.Proc(2)                                    !Illegal call to Proc

!In OneClass.CLW:

MEMBER()

OneClass.BaseProc  PROCEDURE(REAL Parm)

CODE

SELF.Proc(Parm)                                     !Legal call to Proc

OneClass.Proc    PROCEDURE(REAL Parm)

CODE

RETURN(Parm)

!In ThreeClass.CLW:

MEMBER()

ThreeClass.NewProc  PROCEDURE(REAL Parm)

CODE

SELF.Proc(Parm)                                    !Legal call to Proc

See Also:

CLASS

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