CLASS |
![]() ![]() ![]() |
The CLASS statement declares a class module.
Format
CLASS name {MAX.ARGS limit} {INHERITS class.list}
where
QMBasic programs should commence with a PROGRAM, SUBROUTINE, FUNCTION or CLASS statement. If none of these is present, the compiler behaves as though a PROGRAM statement had been used with name as the name of the source record.
The CLASS statement must appear before any executable statements. For more details, see Object Oriented Programming.
The name need not be related to the name of the source record though this eases program maintenance but it must comply with the QMBasic name format rules.
A class module contains the components of a QMBasic object. The general structure of this is
CLASS name PUBLIC A, B(3), C PRIVATE X, Y, Z
PUBLIC SUBROUTINE SUB1(ARG1, ARG2) {VAR.ARGS} ...processing... END
PUBLIC FUNCTION FUNC1(ARG1, ARG2) {VAR.ARGS} ...processing... RETURN RESULT END
...Other QMBasic subroutines... END
The MAX.ARGS option can be used to increase the default limit on the number of arguments permitted in a public function or subroutine within the class module. This has a small effect on performance and should only be used where the default value of 32 needs to be exceeded.
The INHERITS option causes the named class or classes to be inherited automatically by this class when it is instantiated.
See also: Object oriented programming, DISINHERIT, INHERIT, OBJECT(), PRIVATE, PUBLIC. |