This workbook accompanies and should be used in conjunction with the video cassettes and answer diskette also supplied as part of the course. It is not intended to be freestanding. You will find material covered in the video presentations that is not covered in the workbook and vice versa.
This course is aimed at individuals who already have some knowledge of C.
For instance, it is a suitable follow-on course from The C Video Course,
We suggest you watch the video presentation for a given unit, excluding any video workshops at the end. Take brief notes as you watch. Taking notes helps you both to concentrate and remember, but taking too many will cause you to miss points. Feel free to rewind and replay anything you've missed or not grasped.
Once you've watched the video turn to the appropriate material within this workbook and work through it attempting the various tasks presented.
Once you're happy with the topic, watch any video workshops for the unit and, finally, check your answers.
C++ has been an evolving language. It originated in 1980 as a language called 'C with Classes". It was designed and originally implemented by Bjarne Stroustrup at AT&T Laboratories. This implementation was called cfront.
Through the 1980s development of the language lay with AT&T and evolved in response to problems faced by users. Subsequent versions of the cfront C++ compiler supported an increasing number of C++ features. As other C++ vendors appeared, the C++ feature set they supported would be quoted in terms of the cfront compiler with an equivalent feature set.
For instance, a compiler supporting the C++ features of multiple inheritance and type safe linkage would claim to support C++ version 2, as it was version 2 of cfront that originally implemented these features. Similarly, a compiler supporting templates might claim to be at C++ version 3 as it was in this version of cfront that templates first appeared.
During the 1990s C++ has continued to evolve, but now at the behest of the joint ANSI/ISO committees formed to produce a C++ standard. Features added include the bool type and much of the standard C++ library definition. As these committees have been meeting in joint session three times a year, much more frequently than AT&T compiler releases, it has proved more difficult to match a given implementation to a specific feature set. Most compiler vendors "track" the draft standard at a respectful distance. Not so far back that users are upset by missing features; and not so close as to implement features before they reach stability.
The evolving nature of C++ has an impact upon you in several ways.
Firstly, this C++ course has been written to the C++ language specification defined at the time of writing in 1996.
Compilers released before this time will likely not compile all of the examples presented in this workbook or on the disk. Where there are likely to be problems we have indicated this, together with possible workarounds within the footnotes.
Secondly, C++ source code will obviously have been written to the feature
set available at the time of its writing. Code written in 1993, for instance
might contain this line:
int true = 1;
This will receive a syntax error from a modern compiler because true became a C++ keyword with the introduction of the bool type.
You may come across code, therefore, that was once correct, but is not so now.
A third point to note is that just as the design of a building reflects the architectural fashions, the building regulations and the prevalent materials of the time of its construction, likewise the design of a C++ application or library will also reflect the feature set available at the time of its release. Even when a library passes through several versions it is usually not possible to make significant modifications to the design without asking users to completely rewrite existing code that uses that library.
For instance, you will find libraries in which the entire library is derived from something called Object. You might find this confusing because it flies against some of the design principles we outline within the course. However, the reason this was done was to cope with the absence of the C++ feature of templates, a feature that wasn't introduced until later.
An awareness of the fact that the language has been changing, and still is evolving, albeit much more slowly, is an important prerequisite to learning the language. It helps in understanding why there are differences in the code accepted by compilers, and in the code and designs you will meet.
written by Nigel Evans
Silicon River Ltd