Overview

Recommended text books:

Newnes C++ Pocket book, Conor Sexton. ISBN:0-7506-0635-5

Introduction to C++

C++ is a set of language extensions for the C language. One of the aims of C++ was that the C++ code must be no slower than code generated by a C compiler. Another of the main aims of the C++ language was that all the C code was compatible. This was successful with a few exceptions. Modern design methodologies such as objects were to be supported. C++ was developed at AT&T Laboratories by Dr. Stroustrup.

Rubbish. It's nothing of the sort. It can be argued that it's a superset of C, equally, it can be argued that it's a language in it's own right which can also make use of the C functions. But to call it a set of language extensions it's nothing more than laughable!

Chronology of C++

1985

Release 1.0 : The C++ 'compiler' translated the source code into C. The C code was then preprocessed by a true C compiler and linker.

1986

Release 1.1 : A few new language features including 'protected' classes.

1987

Release 1.2 : Improved code generation. The C++ 'compiler' could now work with a wider range of C compilers.

1988

First true C++ compilers available.

1989

Release 2.0 : Multiple inheritance of classes

1990 (?)

Release 3.0 : Compilation time halved, function templates introduced. DOS protected mode (DPMI) now used.

And going by the rest of this book, nothing else happened post 1990!


City & Guilds Assessment

When you have completed this booklet, there are two practical and one written exam to do.

The 2 practical exams are 4 and 12 hours respectively. The written exam is a 1 hour 30 minute multi-choice exam.

The text in the right hand margin, such as (1.2.3) relates to the C&G learning objectives (listed in the appendix). You should sign and date each objective in the appendix as you reach it.

OOP'S CONCEPTS

C++ adds the following key features that are not available in structured programming.

Encapsulation

Inheritance

Polymorphism

ENCAPSULATION

A C++ class can contain both data members and function members. A class can contain any amount of either types. The combination of both data members and function members in one module is called encapsulation. Once a class has been defined it becomes a user defined data type and any instances (objects_ of this type can be defined and used just like any other variable.

The C++ Structure (struct) has also been expanded from the structure designed for C and can contain both data and function members.

This will be covered again, practically.


INHERITANCE

Another object orientated programming technique is called inheritance. Having decided on a group of concepts to model, it is not uncommon to find that several have behaviours and properties in common. These may be separated to form a more general class from which more particular ones may be defined. Hierachies of classes may be developed in this way, each succeeding level incorporating the members of those below them.

It is clear that Man and Women are both derived from Human, but it may be required that Human is derived from Mammal if other classes in the program share the peculiarities of mammals. This will prevent a great deal of duplication of code and also simplify a very complex concept like Human by breaking it down int more managable parts.

This will be covered again, practically.

POLYMORPHISM

The ability to use the same function name and arguments list in many different places is called polymorphism. (Dictionary definition : the existance of various forms in the successive stages of development of an organism).

This will be covered again, practically.