Navigation: Language Reference > 2 - Program Source Code Format > Prototype Attributes >====== PROTECTED (set procedure private to a CLASS or derived CLASS) ====== | |
PROTECTED
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: