Define a Class for Object Oriented Programming
[CREATE] CLASS <ClassName> [ <FROM, INHERIT> <SuperClass1> [,<SuperClassN>] ] [STATIC]
<ClassName> Name of the class to define. By tradition, Harbour classes start with “T” to avoid collisions with user- created classes.
<SuperClass1…n> The Parent class(es) to use for inheritance. Harbour supports Multiple Inheritance.
STATIC This clause causes the class function to be declared as a static function. It will therefore not be available outside the current module.
CLASS creates a class from which you can create objects. The CLASS command begins the class specification, in which the DATA elements (also known as instance variables) and METHODS of the class are named. The following scoping commands may also appear. They control the default scope of DATA and METHOD commands that follow them.
EXPORTED: VISIBLE: HIDDEN: PROTECTED:
The class specification ends with the END CLASS command.
Classes can inherit from multiple <SuperClasses>, and the chain of inheritance can extend to many levels.
A program uses a Class by calling the Class Constructor, usually the New() method, to create an object. That object is usually assigned to a variable, which is used to access the DATA elements and methods.
Harbour’s OOP syntax and implementation supports Scoping (Protect, Hidden and Readonly) and Delegating, and is largely compatible with Class(y)(tm), TopClass(tm) and Visual Objects(tm).
CREATE CLASS TBColumn VAR Block // Code block to retrieve data for the column VAR Cargo // User-definable variable VAR ColorBlock // Code block that determines color of data items VAR ColSep // Column separator character VAR DefColor // Array of numeric indexes into the color table VAR Footing // Column footing VAR FootSep // Footing separator character VAR Heading // Column heading VAR HeadSep // Heading separator character VAR Width // Column display width VAR ColPos // Temporary column position on screen METHOD New() // Constructor ENDCLASS
HBClass(), Object Oriented Programming, DATA, METHOD