The C++ programming language

Resources

My STL tutorial

ACCU's excellent site, with many good book reviews.

Good links

Here is an excellent page from Esa Pulkkinen.

A suggestion for an addition to the STL

A talk on C++ and the STL from Cambridge. Bjarne Stroustrup's home page SGI has a public-domain version of the library with excellent documentation, available at SGI public-domain library and reference.

There is a port of the SGI library by Boris Fomitchev, which works on many current compilers; this is probably the best version to use.

HP provided the first public domain version in 95?. It is still available at ??

ANSI/ISO C++ Draft
Here are the various versions of the ANSI/ISO draft standards, the latest in HTML courtesy of Jason Merrill. The latest is the Dec 96 Working Paper. I look here for subtle details, but getting a general picture from the standard is hopeless.

ObjectSpace apparently no longer provides a port of STL .

XTL: as of 25 Jan 98, unable to find XTL on the web. I saw it some time in late 97, as a commercial version of STL with extensions.

Nikki Locke has a web page at Trumphurst that lists lists a very large number of C++ libraries; it is based on the comp.lang.c++ library list.

The ANSI standard

Local text version

Reserved words

Traits

I think traits are a very important notion that is not yet very well understood by most people in the C++ community.

Here is my take on what traits should be and what they are currently used for.

OOP Generic programming
Class Concept
Inheritance Modeling a concept ADT Trait

There are excellent descriptions of concepts and modeling a concept at Stepanov's web site at SGI.

That is, both "concept classes" (see below) and traits are declarations of a concept (a set of requirements for types, similar to an abstract data type, but traits are designed for the case where there is no inheritance, necessarily). They are similar to java's notion of interfaces, but I don't know java well enough to tell how closely they resemble each other.

Currently, traits aren't quite used like this. Instead, they are used to provide a subset of the requirements of the concept. For example, the type fct1_traits provides the typedefs that are necessary for classes that model 1-arg functions. They define things like the result type, which can then be used by classes such as Compose (as suggested by Koenig and Moo).When defining a unary function, it is recommended that you inherit from the class unary_function, for which fct1_traits are defined. So, I guess in reality, it is a combination of the class unary_function and the fct1_traits that does the job of the ADT.

Iterator traits and function traits have recently been added to the standard, but there are still some things that are missing, IMHO. There is nothing in the trait that relates to complexity, which could be very useful for function traits. Classes like unary_function at the moment do not define the operator(), so they cannot be used a s a base class. Could traits be defined in such a way that inheriting from the "concept class" (for lack of a better name; I mean the class like unary_function) would cause a compile-time error if the class did not satisfy all the requirements?

C++ books

Here are some C++ books that I have looked at in some depth. They are accompanied by my opinions; if you disagree strongly I would be interested in discussing the book by email, though I am very slow at responding to mail...

Tutorials

Stroustrup: C++ Primer (3rd ed).
While still far from perfect, I would classify this as a must-buy for any serious C++ programmer. It has a good coverage of the standard library, and explains very recent ideas such as traits. Get a recent printing, as the early printings had a lot of typos.
Stroustrup: C++ Primer (2nd ed).
Largely obsoleted by Stroustrup's C++ Primer (3rd ed), but well worthwhile second-hand. It covers most of the important features (many of which were not standard when it came out), missing things such as the standard library, bool, RTTI, namespaces, newer template facilities.
Stanley Lippman: C++ Primer (2nd ed.)
If you don't mind missing out on the latest features, this is one of the best tutorials for C++. It covers most of the language, including templates and exceptions, but not namespaces, the new conversion operators, mutable, explicit, template member functions, default arguments to templates, etc. It does not cover the standard library The examples in the book were tested with AT&T 3.0.
Dewhurst and Stark: Programming in C++
Dewhurst and Stark give one of the best early presentations of good object-oriented design. This book does not cover the entire language by any means, and pre-dates many additions (templates and exceptions, particularly), but it is a good base to work from, and much easier to read than any of the other tutorials.

Advanced C++

For those people comfortable with the language and with object-oriented programming, there are a number of good books available.
Scott Meyers: More Effective C++
Scott's second book has almost no overlap with the first. If you liked the first, you should get this. If you haven't read the first one, you should get both. This one appeared in autumn of 1995.

There are excellent descriptions of implementations of smart pointers, reference counting, proxies, etc., with clear explanations of the ramifications of the choices you will have to make. Lots on exception-handling. Not much on generic programming.

[To be continued]


Jak C++
The URL for this document is http://www.jak.org/c++/home.html
Created: Friday 18 July 1997