| **Navigation:**  [[introduction.htm|Language Reference]] > 5 - Declaration Attributes > Variable and Entity Attributes >====== PROTECTED (set variable private to a CLASS or derived CLASS) ====== | [[private set variable private to a class module .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[reclaim reuse deleted record space .htm|{{btn_next_n.gif|Next page}}]] | | || **PROTECTED** {{blk2blue.jpg|blk2blue.jpg}} The **PROTECTED** attribute specifies that the variable on which it is placed is visible only to the PROCEDUREs declared within the same CLASS structure (the methods of that CLASS) and any CLASS derived from the CLASS in which it is declared. This encapsulates the data from any code external to the specific CLASS and its dereived CLASSes. The purpose of the PROTECTED attribute is to provide a level of encapsulation between public and PRIVATE. All PROTECTED data and methods are available for use within their own CLASS and derived CLASSes, but not available to any code outside those specific CLASSes. You could think of these as "semiprivate". **Example:** **OneClass  CLASS,MODULE('OneClass.CLW'),TYPE ** **PublicVar     LONG                  !Declare a Public variable** **ProtectedVar  LONG,****PROTECTED****        !Declare a Protected variable** **BaseProc      PROCEDURE(REAL Parm)  !Declare a Public method** **          END** **TwoClass  OneClass                  !Instance of OneClass** ** CODE** ** TwoClass.PublicVar = 1             !Legal assignment** ** TwoClass.ProtectedVar = 1          !Legal assignment, illegal if PRIVATE** **!OneClass.CLW contains:** ** MEMBER()** ** MAP** **SomeLocalProc  PROCEDURE ** ** END** **OneClass.BaseProc  PROCEDURE(REAL Parm)** ** CODE** ** SELF.ProtectedVar = Parm           !Legal assignment** **SomeLocalProc  PROCEDURE ** ** CODE ** ** TwoClass.ProtectedVar = 1          !Legal assignment** **See Also:** [[class object declaration .htm|CLASS]]