[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
CONSTRUCTOR
Begin definition of a constructor method
------------------------------------------------------------------------------
Syntax:
CONSTRUCTOR [<ctorName>](<parameters>) [,
[<superclass ctor name>](<superclass parameters>)]
Arguments:
<ctorName> is the name of the constructor method. This is
optional - if omitted, the default constructor name is new.
However, for readability, we do not recommend omitting this name,
since the name will appear in the debugger call stack and in error
traces.
<parameters> are the normal Clipper parameters that the
method expects to receive.
<superclass ctor name> is the name of the superclass constructor
which is to be invoked. Again, omitting this name results in the
default constructor name, new, being used.
<superclass parameters> are the parameters expected by the
superclass constructor. These would typically be a subset of the
first parameter list.
Description:
This command begins the definition of a constructor method. A
constructor method is used to initialize newly created objects.
See Constructor Messages and Methods for more information.
Note that if the superclass name and parameters are omitted, and the
class has a superclass, then the superclass new method will still
be invoked, with no parameters.
Sometimes a subclass may not need to perform any work to initialize
itself (perhaps because it has no instance variables). However, the
superclass constructor must still be called, so code such as the
following will usually be required:
CONSTRUCTOR new(p1, p2, p3), (p1, p2, p3)
RETURN
Here, the parameters to the constructor are all passed directly up to
the superclass. A future version of Class(y) will make it uneccessary
to define a constructor method at all in such cases. To anticipate
this, you might wish to make such code conditional as follows:
#ifdef CLASSY_VER100
constructor new(p1, p2, p3), (p1, p2, p3)
return
#endif
The CLASSY_VER100 symbol is defined in CLASS(Y).CH for this purpose.
See Also:
Constructor Messages and Methods
■ new
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson