Table of Contents ChiLib Library Documentation

12. Sample code

12.1. Polymorphic shapes

The shapes1 program demonstrates graphics shapes and the move and scale transformations. The shapes2 program draws a bar chart from rectangles and filled rectangles to show the difference between static and dynamic binding. The shapes3 program utilizes polymorphism to transform an array of arbitrary shapes. The shapes4 program uses multiple inheritance to define the text and traffic sign classes.

12.2. Streams

The grstream program implements the GraphicStream class which derives from ostream to display text on a graphics context. The pstream program implements the persistent streams mechanism.

Each program can be compiled with the preprocessor variable TEST defined to obtain a sample run. Leave TEST undefined to use the stream classes in other programs.

12.3. Simulation

The bank1 program implements the bank simulation without using the simulation framework. The simulation framework code is contained in simfrmwk. The bank2 program uses the framework for the bank simulation.

12.4. Graph editor framework

The gedfrmwk module contains the graph editor framework. The module mouse is required for mouse handling. The graphed1 program implements a very simple instance of the graph editor, using the framework.