The Constructor
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    > BEE Commands
    > Database Operation
    > Content Management
    v Objects and Classes
       o Classes
       v Objects
          o The Constructor
          o Calling an Object Method
          o Polymorphism
          o Inheritance
          o Object within Object
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> Objects and Classes >> Objects >> The Constructor <=  =>      <  1  >  
The function to create the object

Since BEE Objects are just Classes, you can create an object out of thin air by assigning values into the class variables.

Alternatively, you can create an object with a Constructor function.  You define the Constructor function that initialise the class variables through the "this" class.  Then you call this Constructor function with the class name prefix.  For example:

function vehicle

{

   var this%make = "(var)arg%m";

   var this%capacity = "(var)arg%c";

}

 

myVehicle%vehicle m="Toyota" c="4";

 

Every class has a special variable called "function", which contains the references to all the functions (or methods) associated with that class.

For example, var myVehicle%function:new = "vehicle" will define a function "myVehicle%new", which will refer to the function "vehicle" when it is called.  In that case, the constructor call can be rewritten in the following way:

var myVehicle%function:new = "vehicle";

myVehicle%new m="Toyota" c="4";

 

There is a special syntax to express the above in one statement:

var myVehicle% = new vehicle m="Toyota" c="4";

 

The "new" operator is commonly used in calling the constructor, instead of direct call in the first two examples.

However, in BEE Tag, there is not "new" operator and you need to use direct call as in the following:

<beemyVehicle%vehicle m="Toyota" c="4">

 

or

<bee var="myVehicle%function:new" value="vehicle">

<beemyVehicle%new m="Toyota" c="4">

 

 

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd