| xHarbour Reference Documentation > Statement Reference |
![]() |
![]() |
![]() |
Declares the HIDDEN attribute for a group of member variables and/or methods.
HIDDEN:
The HIDDEN: attribute restricts access to member variables and methods of a class. Hidden members can only be accessed in the methods of the class(es) declared in a PRG module. It is the most restrictive attribute. Hidden members cannot be accessed in the context of a FUNCTION or PROCEDURE, only in the context of a METHOD implemented in the declaring PRG module.
A less restrictive visibility attribute is PROTECTED:.
| See also: | CLASS, DATA, EXPORTED:, METHOD (declaration), PROTECTED: |
| Category: | Class declaration , Declaration , xHarbour extensions |
| Header: | hbclass.ch |
| Source: | vm\classes.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example uses two files to demonstrate the protection
// of a hidden member variable outside the declaring PRG module.
** MAIN.PRG uses the class
PROCEDURE Main
LOCAL obj
obj := Test():new( "Hello", "World" )
obj:print() // result: Hello World
? obj:varTwo // result: World
? obj:varOne // Scope Violation <HIDDEN>: VARONE
RETURN
** TEST.PRG declares the class
#include "Hbclass.ch"
CLASS Test
HIDDEN:
DATA varOne
EXPORTED:
DATA varTwo
METHOD init
METHOD print
ENDCLASS
METHOD init( p1, p2 ) CLASS Test
::varOne := p1
::varTwo := p2
RETURN self
METHOD print CLASS Test
? ::varOne, ::varTwo
RETURN self
http://www.xHarbour.com