Try OpenEdge Now
skip to main content
GUI for .NET Primer
Object-oriented Programming in ABL : Classes : Data Members
 

Data Members

Variables defined within the main block of a class are known as data members. Like variables defined in the main block of a procedure, in an internal procedure, or in a user-defined function, data members can be defined as a scalar or an array type, such as CHARACTER, INTEGER, DATE, DECIMAL, LOGICAL, and so on.
In keeping with strong typing, the compiler checks assignments that involve data members at compile time. Assignments involving data members that are considered invalid, for example, performing an integer operation on a character string, are not allowed and raise ERROR. Strong typing allows for catching many potential type errors at compile time. Data members are PRIVATE by default.
Like a variable defined within the main block of a procedure, a data member of a class is scoped to the entire class and can be used freely in methods of the class. Unlike a variable defined within the main block of a procedure, a data member of a class can be defined with an access mode that determines where it can be read or updated. For example:
*PUBLIC — A public data member can be read or updated by the defining class, any inheriting class, or any class that instantiates the class.
*PROTECTED — A protected data member can be read or updated by the defining class and any inheriting class. An instance can access the protected member of a second instance that is at the same level or in a superclass in the class hierarchy.
*PRIVATE — A private data member can be read or updated by the defining class, which is the default access mode. An instance can access the private data member of another instance if both instances are from the same class.