Trusted SF Member
Joined: 26 Aug 2003
Location: Warwickshire, England, UK
|Posted: Sat Aug 27, 2005 4:52 pm Post subject: Book Review - The C++ Programming Language, Special Edition
The C++ Programming Language, Special Edition
Author(s): Bjarne Stroustrup
Publisher: Addison-Wesley http://www.awprofessional.com
Date Published: 2000
Book Specifications: Hardcover, 1020 pages
Category: Programming Languages / C++
Publisher's Suggested User Level: None
Reviewer's Recommended User Level: Programmers (All Levels)
Suggested Publisher Price: $69.99 US / $97.99 CAN
Info from back cover:
Written by Bjarne Stroustrup, the creator of C++, this is the world's most trusted and widely read book on C++.
For this special hardcover edition, two new appendixes on locales and standard library exception safety (also available at http://www.research.att.com/~bs/) have been added. The result is complete, authoritative coverage of the C++ language, its standard library, and key design techniques. Based on the ANSI/ISO C++ standard, The C++ Programming Language provides current and comprehensive coverage of all C++ language features and standard library components.
C++ is a powerful and flexible programming language, with a huge following. Its relationship to C makes it easy to integrate with existing systems, and provides direct access to the C interfaces to many operating systems and libraries. C++ is often used in graphics, sound and system programming, and demonstrates its power, speed and flexibility in a diverse range of situations.
Unlike C, C++ is a large and, in parts, complex language. It is not easy to remember every feature and technicality, and even seasoned C++ programmers frequently make use of reference texts to remind themselves of the syntax for a specific task in C++. If there had to be a single book on C++, it would be this book. The C++ Programming Language, Special Edition is a hardback edition of the 3rd edition. It is one of the most widely used and recommended books in the C++ community.
This book covers not only the core C++ language, but also the C++ STL (Standard Template Library), a flexible generic programming toolkit, and does so with a comprehensive yet comfortable approach to informing the reader.
Chapter Synopsis & Review Comments
The book opens with introductory material, which includes a tour of C++ and the STL. This is an approach used in several programming texts; to show the concepts of the language in use prior to explaining each one in detail. This approach serves to show the reader the wider picture, before focussing on the intimate details. The majority of the book is in 4 parts, each containing several chapters.
Part One contains chapters 4 through 9, Part Two contains chapters 10 through 15, Part Three contains chapters 16 through 22, and Part Four contains chapters 23 through 25. In addition, there are 5 appendices.
Chapter 4 begins the in-depth discussion of C++ with a look at the data types, and declaration structure within the language. For each type introduced, sample code shows a potential usage. This chapter lays the foundations for the rest of the book, as these data types are the basic building blocks used in C++.
Chapter 5 moves on to pointers, arrays and structures. Pointers are a complex subject to introduce for the first time, and this chapter includes a great deal of coverage of the technical details of pointers, which help to prevent users misunderstanding. Code samples illustrate the topics being discussed throughout the chapter, and are often commented to enhance readability. Arrays are closely related to pointers, and are discussed in parallel with pointers in this chapter. This chapter also introduces the C++ concept of a reference, which is similar to a pointer but has subtle differences. Data structures are the topic of the final pages of this chapter, though C++ puts the focus more on classes and object-oriented programming (OOP) than on plain C-style data structures.
Chapter 6 covers the topics of expressions and statements, defining the grammar of C++ and using a running example of a desk calculator, throughout the chapter. The code samples are, again, commented for understanding, and help to illustrate the topics discussed in the main text.
Functions are the focus of chapter 7, which covers declaring and defining functions, passing arguments, overloading functions (the ability to define multiple functions with the same name, but which take different numbers or types of arguments), default arguments and function pointers. Macros are touched on at the end of the chapter, but the advice is to avoid them where possible. Again, this chapter contains plenty of code to go along with the discussion.
Chapter 8 introduces namespaces and exceptions, two C++ concepts which do not have direct parallels in C. The chapter discusses modularisation of code, interfaces and namespaces, before moving into a discussion of exceptions; unexpected situations which may arise at runtime. C++ provides mechanisms to manage (handle) exceptions, and these are presented in this chapter, with commented code examples throughout.
Chapter 9 looks at some important topics relating to programming in C++, discussing the ways in which C++ source can be managed. Separate compilation of source files is discussed along with the topic of linkage. Suggestions for organising code and header files are presented, as is a section on linking to non-C++ code.
Chapter 10 marks the beginning of the discussion of abstraction in C++ with the introduction of classes. Classes provide the programmer with the ability to create new types, and the other C++ components, such as operator overloading, allow such classes to work with the same syntax as built-in types. Chapter 10 introduces classes and OOP, discussing member functions, constructors, and operator overloading . Code illustrates the examples and concepts introduced, and reinforces the explanations given.
Chapter 11 is dedicated to operator overloading; an important concept in C++, which allows classes to be used much like built in types (for instance a ComplexNumber class could have the + operator defined for addition). The running example in this chapter is, indeed, a complex number class, and Stroustrup discusses the ways in which it can be made to work just like any other numeric type, such as an int (integer), as far as writing C++ code is concerned. The included code highlights the information given and helps to clarify the complex topics discussed.
Chapter 12 jumps back onto the OOP train with a look at derived classes. Class hierarchies are an important way to represent real-world inter-relations between systems, and C++ offers flexibility in this respect. Chapter 12 covers derived classes in detail, including technicalities such as order of constructor / destructor call, virtual functions, abstract classes and class hierarchies.
Chapter 13 introduces yet another powerful C++ feature - templates. This chapter details the mechanism by which it is possible to create a template class or function which can be adapted to use a variety of data types. Templates are incredibly useful in making flexible, generic code, and this chapter covers these powerful constructs in detail.
Chapter 14 expands on the coverage of exceptions in chapter 8, looking at exception handling in detail. The discussion covers exceptions from every angle, looking at how to throw and catch exceptions, managing resources, exceptions in constructors or destructors, uncaught exceptions, rethrowing, and standard exceptions.
Class hierarchies are discussed in chapter 15, which covers multiple-inheritance, the ability of a class to have more than one base class. Many languages frown on multiple-inheritance for the complexities which can arise from its use, but the advice given in this chapter should prove useful in avoiding such situations, and emphasises the flexibility of C++ in allowing multiple inheritance.
Chapter 16 brings with it the beginning of part 3, and the topic swiftly changes to the standard library. The C++ STL provides generic containers and algorithms for generic programming. Chapter 16 introduces the library organisation and the containers provided.
Chapter 17 discusses the standard containers; template classes for storing a variety of data types. The chapter discusses the standard vector, list, deque (double ended queue), stack, queue, priority queue, map, multimap, set and multiset, as well as some specialised containers such as the bitset. Arrays, hash tables and hash maps round off the chapter.
Chapter 18 breaks into the standard algorithms provided by the STL. The chapter covers algorithms for iteration, searching, sorting, copying, set operations and permutations. The included code illustrates each algorithm in several situations.
Iterators and allocators are the topic of chapter 19. These work in conjunction with containers and algorithms to bind everything together.
Chapter 20 presents the C++ standard string class and its functions. The topics covered include characters, element access, constructors, errors, assignment and conversion to C-style character arrays. The chapter ends with a detailed look at the string operations provided by the standard string.
Chapter 21 introduces streams; the input/output (I/O) mechanism of C++. Topics covered include output, input, stream states, I/O of user-defined types, exceptions, formatting and file streams.
Chapter 22 discusses numerics. While C++ was not designed specifically for numeric work, it is a general programming language and does provide some features for numerics. This chapter looks at numeric limits, mathematical functions and random number generation.
Chapter 23 is the point at which part 5 begins, and moves away from the core language or standard library topics into a more abstract discussion of design using C++. Chapter 23 is a discussion of design and development, and includes some useful ideas for designing software in C++.
Chapter 24 covers design and programming, linking together the core C++ concepts introduced throughout the book with a detailed look at designing software using those features of the language.
Chapter 25 looks at the role of classes in C++ development. The three design chapters serve to reinforce the topics of the rest of the book, and bring it all together into a final "big picture" understanding of the C++ programming language.
The appendices cover, in order, C++ Grammar, Compatibility, Technicalities, Locales, and Standard-Library Exception Safety.
Style and Detail
This book, from beginning to end, reads fluently and coherently. It is an excellent book from which to learn C++, but also serves as a valuable reference for the rest of a programmers time using C++.
The code included in the book is always just enough to illustrate the point, without forcing the reader to go through pages and pages of code listings with no end in sight and no obvious point. All of the code is commented to explain what it does - or doesn't do - and gets to the point instantly.
While this book does not cover every aspect of the STL, or Templates in minute detail, it does introduce and discuss the major concepts, those which should be adequate for most C++ work, and the coverage of the core language is unparalleled. Other books exist to explain every last detail of the STL and Templates; this book provides an excellent C++ tutorial and reference.
Each chapter begins with an introductory statement, explaining the concepts to be introduced and providing a general roadmap for the book. Chapters end with a section of advice, bullet-pointed statements summarising the advice given with the coverage of each topic within the chapter, and a list of exercises which utilise the information provided in the chapter.
The comprehensive coverage of the features of C++, matched with the authors expert advice and recommendations throughout, make this book an interesting and immersing read. To give this book anything less than 10 on the SFDC review scale would be criminal.
If you are a C++ programmer, or plan on being one, and do not already have this book, it should be added to your shopping list immediately. It is a classic programming text amongst C++ programmers, and is respected world-wide for its coverage of this powerful, flexible language.
This book receives an honoured SFDC Rating of 10/10.
Keywords: C++, programming, templates, classes, standard library
This review is copyright 2005 by the author, Andrew J. Bennieston, and Security-Forums Dot Com, and may not be reproduced in any form in any media without the express permission of the author, or Security-Forums Dot Com.