Synopses & Reviews
In chess, learning the rules for how the pieces move is simply the first step; to master the game, you must understand the strategies and tactics that guide each move. The same applies to C++. Knowing the right strategies helps you avoid the traps and work more effectively. Luminary Rob Murray helps beginning to intermediate C++ programmers take that next step by sharing his experience and advice.
Practical code examples are used throughout to illuminate useful programming strategies and warn against dangerous practices. To further ensure comprehension, each chapter ends with a list of the key ideas introduced in that chapter, along with questions to stimulate thought and discussion.
You'll begin by learning how to choose the right abstractions for your design, taking care to preserve the distinction between abstraction and implementation. You'll then look at the process of turning an abstraction into one or more C++ classes, with discussions ranging from high-level design strategies to low-level interface and implementation details.
Single and multiple inheritance are explored in depth, beginning with a discussion of where they fit in a design and followed by detailed examples that show how the concepts are used in practice. A separate chapter covers the techniques of building classes from which others can derive, and discusses the benefits - and costs - involved.
Rob Murray offers unprecedented insight into the new templates feature, beginning with the basics and walking you through several real-world examples. The author also describes a variety of specific techniques to make your programs faster, more reusable, and more robust. Exceptions are another new C++ feature; Murray gives advice on when they should - and should not - be used. The book concludes with a look at the process of moving a project from C to C++, exploring the human issues as well as the technical ones.
About the Author
Robert B. Murray is President of Sarajen Software, an object-oriented software consulting company in Irvine, California. He was formerly with AT&T Bell Labs, where he was involved in the development of the C++ language, compilers, and libraries. He is the founding editor of The C++ Report
, and has been teaching C++ tutorials at academic and professional conferences since 1987.
Table of Contents
A Note about The Code Examples.
A Road Map.
The Language Rules.
A Telephone Number Abstraction.
Relationships Between Abstractions.
Worrying about the Boundary Conditions.
Designing with CRC Cards.
Implicit Type Conversions.
Overloaded Operators: Members or Nonmembers?
Overloading, Defaults, and Ellipsis.
Questions. CHAPTER = 3. Handles.
Avoiding Copies with Use Counts.
Avoiding Recompilations: The Cheshire Cat.
Using Handles to Hide the Design.
Handles as Objects.
The is-a Relationship.
Conformance to Base Class Abstractions.
Pure Virtual Functions.
Inheritance Details and Traps.
5. Multiple Inheritance.
Multiple Inheritance as Set Intersection.
Virtual Base Classes.
Some Multiple Inheritance Details.
6. Designing for Inheritance.
The Protected Interface.
Should You Design for Inheritance?
Design for Inheritance: Some Examples.
A Pair Class Template.
Some Template Details.
Expression Arguments to Templates.
8. Advanced Templates.
Container Classes Using Templates.
Example: A Block Class.
Detailed Block Design Issues.
Containers with Iterators: A List Class.
Iterator Design Issues.
Constraints on Template Arguments.
Discovery and Acquisition.
Alternative Memory Allocation Schemes.
Passing Arguments to Operator New.
Managing External Resources.
Finding Memory Bugs.
Don't Guess, Measure!
Bottlenecks in Dynamic Memory Allocation.
An Example Exception.
Exceptions Should Be Exceptional.
Designing the Exception Object.
11. Moving Your Project to C++.
Design and Implementation.
Developing an Asset Base.
A Closing Thought.