Freigeben über


Protection and Hiding of Class Members

You can protect or hide properties and methods in a class definition with the PROTECTED and HIDDEN keywords of the DEFINE CLASS command.

For example, if you create a class to hold employee information, and you don't want users to be able to change the hire date, you can protect the HireDate property. If users need to find out when an employee was hired, you can include a method to return the hire date.

DEFINE CLASS employee AS CUSTOM
PROTECTED HireDate
  First_Name = ""
  Last_Name = ""
  Address = ""
  HireDate = { - - }

PROCEDURE GetHireDate
  RETURN This.HireDate
ENDPROC
ENDDEFINE

See Also

Writing Class Definitions Programmatically | Programmatic Class Definitions | Creation of Objects from Classes | Event Response | Object-Oriented Programming