Quick start manual

Classes and objects
7-1
Chapter
7
Chapter7
Classes and objects
A class, or class type, defines a structure consisting of fields, methods, and properties.
Instances of a class type are called objects. The fields, methods, and properties of a
class are called its components or members.
A field is essentially a variable that is part of an object. Like the fields of a record, a
class’s fields represent data items that exist in each instance of the class.
A method is a procedure or function associated with a class. Most methods
operate on objects—that is, instances of a class. Some methods (called class
methods) operate on class types themselves.
A property is an interface to data associated with an object (often stored in a field).
Properties have access specifiers, which determine how their data is read and
modified. From other parts of a program—outside of the object itself—a property
appears in most respects like a field.
Objects are dynamically allocated blocks of memory whose structure is determined
by their class type. Each object has a unique copy of every field defined in the class,
but all instances of a class share the same methods. Objects are created and destroyed
by special methods called constructors and destructors.
A variable of a class type is actually a pointer that references an object. Hence more
than one variable can refer to the same object. Like other pointers, class-type
variables can hold the value nil. But you don’t have to explicitly dereference a class-
type variable to access the object it points to. For example, SomeObject.Size := 100
assigns the value 100 to the Size property of the object referenced by SomeObject; you
would not write this as SomeObject^.Size := 100.