Inheritance
Username:  
Password:
  > Home
v User Guide
    > Introduction
    > Hello World
    > Flow Control
    > Function Calls
    > Authentication
    > Database access
    > Content Management
    > Remote Calling
    v Object-Oriented
       o Constructor
       o Object function
       o Polymorphism
       o Inheritance
       o Object within an object
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Object-Oriented >> Inheritance <=  =>      <  1  >  
Inheritance

Inheritance in BEE is done by the child's constructor calling the parent's, so the object have all the child's variables (object attributes) and functions (method), PLUS all the parent's variables and functions.

In the following example, Vehicle has two Child classes: car and plane.  We use the same constructor vehicle in the previous example and create two more:

function vehicle

{

   var this%make = "{arg%m}";

   var this%capacity = "{arg%c}";

   var this%function:do = "dontknow";

}

 

function car

{

   this%vehicle m="{arg%m}" c="{arg%c}";

   var this%wheel = "{arg%w}";

   var this%function:do = "drive";

}

 

function plane

{

   this%vehicle m="{arg%m}" c="{arg%c}";

   var this%engine = "{arg%e}";

   var this%function:do = "fly";

}

 

function drive

{

   display "{arg%who} drive {arg%this}<br>\n";

}

 

function fly

{

   display "{arg%who} fly {arg%this}<br>\n";

}

 

function dontknow

{

   display "{arg%who} don't know what to do with {arg%this}<br>\n";

}

 

var myCar% = new car m="Toyota" c="4" w="alloy";

var myPlane% = new plane m="Boing" c="400" e="jet";

var mySpaceship% = new vehicle m="Alien Nation" c="4000";

 

myCar%do who="I";

myPlane%do who="You";

mySpaceship%do who="We";

 

 

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