Preface 17
implementation are as important as the language itself. Most vendors’
documentation concerning their own implementation specifics is adequate.
Chapters
C++ is a language where new and different features are built on top of an existing syntax.
(Because of this it is referred to as a
hybrid
object-oriented programming language.) As more
people have passed through the learning curve, we’ve begun to get a feel for the way
programmers move through the stages of the C++ language features. Because it appears to be
the natural progression of the procedurally-trained mind, I decided to understand and follow
this same path, and accelerate the process by posing and answering the questions that came to
me as I learned the language and that came from audiences as I taught it.
This course was designed with one thing in mind: to streamline the process of learning the
C++ language. Audience feedback helped me understand which parts were difficult and
needed extra illumination. In the areas where I got ambitious and included too many features
all at once, I came to know – through the process of presenting the material – that if you
include a lot of new features, you have to explain them all, and the student’s confusion is
easily compounded. As a result, I’ve taken a great deal of trouble to introduce the features as
few at a time as possible; ideally, only one major concept at a time per chapter.
The goal, then, is for each chapter to teach a single concept, or a small group of associated
concepts, in such a way that no additional features are relied upon. That way you can digest
each piece in the context of your current knowledge before moving on. To accomplish this, I
leave some C features in place for longer than I would prefer. The benefit is that you will not
be confused by seeing all the C++ features used before they are explained, so your
introduction to the language will be gentle and will mirror the way you will assimilate the
features if left to your own devices.
Here is a brief description of the chapters contained in this book:
(5) Introduction to iostreams
. One of the original C++ libraries – the one that provides the
essential I/O facility – is called iostreams. Iostreams is intended to replace C’s
stdio.h
with an
I/O library that is easier to use, more flexible, and extensible – you can adapt it to work with
your new classes. This chapter teaches you the ins and outs of how to make the best use of the
existing iostream library for standard I/O, file I/O, and in-memory formatting.
(15) Multiple inheritance
. This sounds simple at first: A new class is inherited from more
than one existing class. However, you can end up with ambiguities and multiple copies of
base-class objects. That problem is solved with virtual base classes, but the bigger issue
remains: When do you use it? Multiple inheritance is only essential when you need to
manipulate an object through more than one common base class. This chapter explains the
syntax for multiple inheritance, and shows alternative approaches – in particular, how
templates solve one common problem. The use of multiple inheritance to repair a “damaged”
class interface is demonstrated as a genuinely valuable use of this feature.