win.__classBase - WIN
Class __classBase
The __classBase object provides the base class functionality.
To derive a class from a base class use the base method. To
instantiate an object use new.
To derive a class:
myClass = win.__classBase:base ()
function myClass:constructor (name)
-- call the base constructor
if not win.__classBase.constructor (self) then
return nil
end
-- define any properties and set up
self.name = name
-- return self or nil on error
return self
end
function myClass:get_name ()
return self.name
end
To instantiate:
myObject = myClass:new ("John Doe")
print (myObject:get_name ())
The methods of __classBase inherit to any derived classes, which can
again be derived from. To call a base class method for an overridden
method, call the method of the base class definition object with the
dot operator and an extra first parameter of the instantiated
object.
Methods
See also API
Reference, WIN.
win.__classBase:base
class __classBase:base ()
Returns a class object that inherits from the base class.
Parameters
none
Returns
class |
table |
The class object that inherits from the base
class. |
Remarks
Use this method to inherit from a base class for a derived class
definition object. This method is inherited and can be called to
derive from any class definition object derived from __classBase.
top
win.__classBase:constructor
object __classBase:constructor ( ... )
This method is called during the instantiation process with the
parameters passed to new.
Parameters
... |
any |
The parameters passed to new. |
Returns
object |
table |
The instantiated object. |
Remarks
The constructor should call the base class constructor, define any
properties for the class and do any setting up of the class object.
If a derived class does not override this method the base class's
constructor will be called.
top
win.__classBase:new
object __classBase:new ( ... )
Instantiates and returns a new class object, or nil if instantiation
failed.
Parameters
... |
any |
Any parameters necessary for the class.
__classBase takes none. |
Returns
object |
table |
The instantiated class object, or nil if
instantiation failed. |
Remarks
Use this method to instantiate an object derived from __classBase.
top
See also API
Reference, WIN.