ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6


4 - Big Parent, Teeny Children

This means the children classes need only include a few calls for class-specific behavior, which helps explain their smaller size. In fact, for most classes, only a few calls are defined:

class CObjCheckBox : public CBaseObject
{

  private:

    enum { INDEX_CAPTION, INDEX_CLASS, INDEX_HEIGHT, 
           INDEX_LEFT, INDEX_NAME, INDEX_TOP, INDEX_WIDTH, };

    static const s_property s_propertyTable[];

    void ObjectClassConstructor(char *buff);
    void ObjectDraw(TCanvas *canvas,int left,int top,int width,int height);

  public:

    CObjCheckBox(void);
};

The CObjCheckBox class inherits publicly from the base class, making all the public base class functions accessible. This means the program can work with the base class pointers and the calls found there, without any problems - in fact, it's only on object creation that the program is aware of what kind of CBaseObject child it is dealing with.

For CObjCheckBox , only three functions are needed to make the class distinctive: ObjectDraw (which physically draws the object on the editor screen), ObjectClassConstructor (which creates the text string used in the program's source code output), and the constructor.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice