Department of Engineering

IT Services

Introduction

This document is aimed at those who have done 1A and 1B C++ courses at CUED, but it should be useful to experienced C people too.

The 1A/1B courses introduce all C++'s loop constructions and many of the operators. Array and class creation was also introduced. However some issues (e.g. Makefiles) were glossed over, others were used in artificial conditions, and many things were not touched upon at all. Some of these newer things are easy conceptually, and fundamental to modern C++ programming, though implementation details can be complicated. The pay-off comes when you use the Standard Library - a library which exploits advanced C++ features to make life easy for the programmer.

C++ can be used in various ways: procedural (like Fortran or C); Object-orientated; Generic, etc. This document covers the techniques to support each of these programming paradigms, dealing with

  • Namespaces
  • Using classes to build new classes - inheritance
  • Abstract Classes and Templates
  • Using the Standard Library
  • Techniques useful when writing big, project-sized programs.

It ends with an example of a real-life program. The online source of this provides examples of the above subjects to supplement the examples in this document.

To aid readability, the examples in the text are mostly code fragments. Full program listings are online.

A few programming exercises are suggested in this document. Any computing book will offer more.

Unless otherwise stated, the page numbers in the margin refer to ``The C++ Programming Language'' (third edition), Bjarne Stroustrup, AT&T, 1997.