The Hands-On C++ Seminar
Taught by Chuck Allison
Chuck created the Thinking in C CD ROM that is packaged with both
Thinking in C++ and
Thinking in Java.
Click here to learn more about Chuck.
Hosted by Bruce Eckel
- Covers all the essential features of the Standard C++ language.
- Designed to bring seasoned C programmers into C++ as rapidly as possible.
- Created by Bruce Eckel, who has over 10 years of experience teaching seminars.
- Based on Thinking in C++, 2nd Edition, Vol. 1, the first edition of
which won the Software Development Magazine
"Jolt" award for best book.
- See the Java Seminar Page
for recent testimonials about these seminars.
The emphasis of this hands-on, exercise-based course is understanding OOP
and how C++ implements the features of OOP, and in learning the features of the
language which are in common use so programmers can comfortably read typical C++
code. Topics are presented a step at a time, with a focus on individual features
and their motivation. Following each step, one or more exercises will be worked
by the class so students learn the techniques through direct experience.
Many of the language features will be examined for their effect on size and
speed overhead, so programmers may understand which features are "free," which
are "expensive," and how to reasonably migrate to C++. Design issues will be
presented in the context of language features.
Bring your copy of Bruce Eckel's Thinking in C++, 2nd Edition
(Prentice-Hall, 2000), which will be used as the text for the class. The CD in
the back of the book includes the source code, and students will receive printed
slides as handouts.
- Introduction to Object-Oriented Programming: Programming for Change.
This section introduces the course and gives an introduction to the basic concepts
and features of OOP as well as an introduction to analysis and design. We then discuss
making the transition from C to C++.
- Making and Using Objects. Most features in C++ revolve around this key
concept: making and using new data types, classes, in C++. Here we introduce
some of the key classes as well C++ syntax and programming concepts.
- Data Abstraction: structs + functions = data types. The simple idea of putting
functions into structs lays the groundwork for more powerful OOP abilities.
- Hiding the Implementation for Code Control. You can decide that some
of the data and functions in your structure are unavailable to the user of the
new type by making them private. This means you can separate the
underlying implementation from the user's interface and, thus, allow for that
implementation to be easily changed without affecting the user's code. The
keyword class is also introduced as a fancier way to describe a new data
type, and the meaning of the word "object" is demystified.
- Guaranteed Initialization and Cleanup. One of the most common C
errors results from un-initialized variables. The constructor in C++ lets you
guarantee that variables of your new data type (a.k.a. "objects of your class")
will always be properly initialized. If your objects also require some sort of
cleanup, you can guarantee that this cleanup will always happen with the C++
- The Convenience of Function Overloading & Default Arguments.
C++ is intended to help you develop big, complex projects. Since you may be using
multiple librarieswith the same function names, function overloading allows
you to re-use the same function name as long as the
argument lists are different. Default arguments let you call the same function
in different ways by automatically providing default values for some of your
- Using Constants for Object and Program Safety. The const
and volatile keywords have additional meaning in C++, as well as different
meanings inside and outside classes. You'll also see what applying const to
- Inline Functions: Do's and Don'ts of Optimizing. Preprocessor macros
eliminate function call overhead, but the preprocessor also eliminates valuable
C++ type checking. The inline function gives you all the benefits of a
preprocessor macro plus all the benefits of a real function call.
- Name Control for Large-Project Construction. Creating names is a
fundamental activity in programming, and when a project gets large, the number
of names can be overwhelming. This section shows how the static keyword
is used to control visibility and linkage, and its special meaning with classes.
A more useful technique is C++'s namespace feature, which allows you to
break up the global name space into distinct regions.
- References & the Copy-Constructor: When to Pass by Value.
C++ pointers work like C pointers with the added benefit of stronger C++ type
checking. From Algol and Pascal, C++ lifts the reference, which lets the
compiler handle the address manipulation while you use ordinary notation.
You'll also meet the copy-constructor, which controls the way objects are
passed into and out of functions by value.
- Operator Overloading or "Syntactic Sugar". This
feature is sometimes called "syntactic sugar", as it lets you sweeten the syntax
for using your type by allowing operators as well as function calls. In this
section, you'll learn how operator overloading is really just a different type
of function call, and you'll learn how to write your own.
- Dynamic Object Creation: Creating and Destroying Objects at
Run-Time. In the general programming problem, you can't know the quantity,
lifetime, or type of the objects needed by your running program. In this
section, learn how C++'s new and delete elegantly solve this
problem by safely creating objects on the heap.
- Creating New Types with Inheritance & Composition. Data
abstraction allows you to create new types from scratch; with inheritance and
composition you can create new types from existing types. Inheritance lets you
create a more specific version of an existing type; with composition you
assemble a new type using other types as pieces. In this section you'll learn
the syntax, how to redefine functions, and construction and destruction for
inheritance and composition.
- Polymorphism & virtual Functions Made Simple. On your own,
you might take nine months to discover and understand this cornerstone of OOP.
Through small, simple examples you'll see how to create a family of types with
inheritance and manipulate objects in that family through their common base
class. The virtual keyword lets you treat all objects in this family
generically, which means that the bulk of your code doesn't rely on specific
- Templates, Container Classes, and the Standard C++ Library.
Inheritance and composition let you reuse object code, but that
doesn't solve all your reuse needs. Templates let you reuse source code
by providing the compiler with a way to substitute type names in the body of a
class or function. This gives essential support for container class libraries,
which are important tools for the rapid, robust development of programs (the
Standard C++ Library includes a significant library of container classes).
This course assumes you're a C programmer, since it is intended to move
you from C into C++, and not to teach the C language. If you haven't been
exposed to C, Chuck Allison's Thinking in C: Foundations for C++ & Java CD,
packaged with the book, is a multimedia seminar of synchronized slides and audio
lectures designed to introduce you to the aspects of C necessary for you to move
to C++. People have often recommend The Waite Group's C Primer Plus as
an introduction to C (personally, I learned from Jack Purdum's C Programming
Guide which I liked very much. It may still be available, from Que). This
is a challenging course; we'll move through the essential features of the
C++ language, with exercises, in five days. Our goal is to give you enough
learning experiences to push you to your limit, but not beyond.
What You Need
A notebook computer with an installed and tested C++
compiler. This should be the compiler you plan to develop with, since they all
have idiosyncrasies (some quite significant) and by trying the exercises with
your particular compiler you can learn in class what they are (with a teacher
there who can distinguish for you the difference between a bug and a feature).
It's very important that you properly install your compiler AND perform a test
by compiling and running one or more sample programs. It is sometimes
impossible to fix an improper installation during the class. If you're not
sure, make sure you bring what you need to re-install the software (e.g. CD-ROM
drive and the software CD).
If you don't yet have a favorite C++ compiler,
Borland's C++ 5.5
is available free.
If you're a Unix programmer, it's best to find one of the Unixes that
will run on a PC platform and install it on a notebook computer. Again, having
the compiler in class that you're planning to use for your development will
provide you with the most value in class.