xHarbour Reference Documentation > Statement Reference xHarbour Developers Network  

HIDDEN:

Declares the HIDDEN attribute for a group of member variables and/or methods.

Syntax

HIDDEN:

Description

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:.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe