Resources

The use of class libraries in C++

Aims

To enable students to:

  1. understand class libraries

  2. use class libraries

Understand class libraries

Many companies produce compilers, examples include Borland, IBM, Microsoft, Weitek, etc. Essentially these products all server the same purpose, to convert source code written in C++ into executable programs. To differentiate their products these companies use various techniques, including appearance, cost, functionality and performance.

One of these differentiates, performance, includes class libraries for many companies. A class library is a collection of classes written by the compiler writers for the developers using their product. These classes cover many areas such as ways of storing data, interaction with the user, control of system resources and the like.

The compiler used in class, Borland Turbo C++, contains a class library. Although in modern terms it is very rudimentary, it provides some insight into the features that can be expected from a class library.

Using the Windows Explorer navigate to the classlib directory below the tc directory, for example c:tcclasslib. Within this directory is a file called classlib.doc which should be read.

After reading classlib.doc you should have an understanding of the facilities offered by the class library shipped with Borland Turbo C++. Some of the classes would have been useful in the work done to date.

Use class libraries

In order to use the class libraries with Borland Turbo C++ a few modifications to the compilers configuration must be made. From the Options menu select the Directories entry. Into the include and library entries add the corresponding values for the class library, i.e. c:tcclasslibinclude to include and c:tcclassliblibdirectory to library.

Having added these entries a new set of classes are now available for use within your programs, for example by adding a statement to include the file queue.h into your source files the class Queue is now available.

By studying the header and source files for the classes a greater understanding of object oriented programming techniques may be obtained.

Questions

Re-write the program produced in the classes lecture that handled stacks to make use of the class library.

Downloads