Try OpenEdge Now
skip to main content
Object-oriented Programming
Getting Started with Classes, Interfaces, and Objects : Defining classes : Defining state in a class : Data members and properties
 
Data members and properties
You define data members and properties of a class in the main block of the class, outside of any method definitions for the class. Class data members and properties have an access mode that determines where and how you can access the data member or property. Private data members or properties are accessible from within the class where they are defined. An instance can access a private data member or property of another instance if they are both instances of the same class. Protected data members or properties are accessible from within the class where they are defined and in any subclass of the defining class. An instance can access a protected member of a second instance of a class that is at the same level or in a super class in the class hierarchy. Public data members or properties are accessible both within the class hierarchy and from outside the class hierarchy where they are defined. To fully encapsulate the data members of a class, you typically make each data member private and access it indirectly through a public property or public method, as appropriate.
You can define data members as a wide variety of ABL data elements, including variables, temp-tables, ProDataSets, and other handle-based objects. Of these data members, only variables can be PUBLIC. Variables and some other data members can be defined as object references to other class-based objects that the class instantiates. You can define a property as any data type that a method or user-defined function can return as a value, including an object reference or ABL array.