Creating Composite Classes

A composite class is a class that has members that are themselves instances of other classes. A perfect example of this is a class that is based on a container class such as a form. When you think of it, a form in and of itself is a class. Yet the objects in it are classes also. So, we have one object that has other objects contained in it (hence the name Container Class).

When using code, object members are added to the class in the INIT method using the ADDOBJECT() method. For example, I could have a class called PHONE that I wanted to have a member of class LIGHT. In the INIT method of class PHONE, I would do the following:


PROCEDURE init
    this.addobject("oLight", "Light")
ENDPROC

If I instantiated an object called oPhone, it would have a member called oLight.

The syntax of the AddObject() method is:


<object>.AddObject(<Member Name>,<Class Name>)