User Tools

Site Tools


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

 

PRIVATE

blk2blue.jpg

The PRIVATE attribute specifies that the PROCEDURE on whose prototype it is placed may be called only from another PROCEDURE within the same source MODULE. This encapsulates it from other modules.

PRIVATE is normally used on method prototypes in CLASS structures, so that the method may only be called from the other CLASS methods in the module. PRIVATE methods are not inherited by CLASSes derived from the CLASS containing the PRIVATE method's prototype, although they can be VIRTUAL if the derived CLASS is contained in the same module.

Example:

MAP

 MODULE('STDFuncs.DLL')                !A standard functions .DLL

Func49 PROCEDURE(SREAL),REAL,PASCAL,PROC

Proc50 PROCEDURE(SREAL),PRIVATE         !Callable only from Func49

 END

END

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

BaseProc   PROCEDURE(REAL Parm)         !Public method

Proc       PROCEDURE(REAL Parm),PRIVATE !Declare a private method

     END

TwoClass  OneClass                      !Instance of OneClass

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)

See Also:

CLASS

private_set_procedure_private_to_a_class_or_module_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)