SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Third Edition now available! |
Written by the designer of C++, Bjarne Stroustrup, The C++ Programming Language is the definitive guide to the language, its fundamental principles, and key techniques for mastering it. The C++ Programming Language provides coverage of all C++ features, including exception handling, templates (parameterized types), and the latest ANSI/ISO extensions. The C++ Programming Language is the cornerstone of every C++ programmer's library.
FeaturesErrata for the book, and brief updates on the progress of C++ standardization are available via ftp at:
ftp://ftp.aw.com/cseng/authors/stroustrup/stroustrup2e/ Preface.
Preface to the First Edition.
Contents.
Notes to the Reader.
1. A Tour of C++.
Introduction.
Programming Paradigms.
"A Better C".
Support for Data Abstraction.
Support for Object-Oriented Programming.
Limits to Perfection.
2. Declarations and Constants.
Declarations.
Names.
Types.
Literals.
Named Constants.
Saving Space.
Exercises.
3. Expressions and Statements.
A Desk Calculator.
Operator Summary.
Statement Summary.
Comments and Indentation.
Exercises.
4. Functions and Files.
Introduction.
Linkage.
Header Files.
Linkage to Non-C++ Code.
How to Make a Library.
Functions.
Macros.
Exercises.
5. Classes.
Introduction and Overview.
Classes and Members.
Interfaces and Implementation.
Minor Class Features.
Construction and Destruction.
Exercises.
6. Derived Classes.
Introduction and Overview.
Derived Classes.
Abstract Classes.
A Complete Program.
Multiple Inheritance.
Access Control.
Free Store.
Exercises.
7. Operator Overloading.
Introduction.
Operator Functions.
User-defined Type Conversion.
Literals.
Large Objects.
Assignmetn and Initialization.
Subscripting.
Function Call.
Dereferencing.
Increment and Decrement.
A String Class.
Friends and Members.
Caveat.
Exercises.
8. Templates.
Introduction.
A Simple Template.
List Templates.
Function Templates.
Template Function Overloading Resolution.
Template Arguments.
Derivation and Templates.
An Associative Array.
Exercises.
9. Exception Handling.
Error Handling.
Discrimination of Exceptions.
Naming of Exceptions.
Resource Acquisitions.
Exceptions that are not Errors.
Interface Specifications.
Uncaught Exceptions.
Error-Handling Alternatives.
Exercises.
10. Streams.
Introduction.
Output.
Input.
Formatting.
Files and Streams.
C Input/Output.
Exercises.
11. Design and Development.
Introduction.
Aims and Means.
The Development Process.
Management.
Rules of Thumb.
Annotated Bibliography
12. Design and C++.
Design and Programming Language.
Classes.
Components.
Interfaces and Implementations.
Rules of Thumb.
13. Design of Libraries.
Introduction.
Concrete Types.
Abstract Types.
Node Classes.
Run-time Type Information.
Fat Interfaces.
Application Frameworks.
Interface Classes.
Handle Classes.
Memory Management.
Exercises.
Reference Manual.
ANSI/ISO Resolutions.
Index. 0201539926T04062001
"The road goes ever on and on".
----Bilbo Baggins
As promised in the first edition of the book, C++ has been evolving to meet the needs of its users. This evolution has been guided by the experience of users of widely varying backgrounds working in a great range of application areas. The C++ user community has grown a hundredfold during the six years since the first edition of this book; many lessons have been learned, and many techniques have been discovered and/or validated by experience. Some of these experiences are reflected here.
The primary aim of the language extensions made in the last six years has been to enhance C++ as a language for data abstraction and object-oriented programming in general and to enhance it as a tool for writing high-quality libraries of user-defined types in particular. A "high-quality library," is a library that provides a concept to a user in the form of one or more classes that are convenient, safe, and efficient to use. In this context, safe means that a class provides a specific, type-safe interface between the users of the library and its providers; efficient means that use of the class does not impose significant overheads in run-time or space on the user compared with handwritten C code.
This book presents the complete C++ language. Chapters 1 through 10 give a tutorial introduction; Chapters 11 through 13 provide a discussion of design and software development issues; and, finally, the complete C++ reference manual is included. Naturally, the features added and resolutions made since the original edition are integral parts of the presentation. They include refined overloading resolution, memory management facilities, and access control mechanisms, type-safe linkage, const and static member functions, abstract classes, multiple inheritance, templates, and exception handling.
C++ is a general-purpose programming language; its core application domain is systems programming in the broadest sense. In addition, C++ is successfully used in many application areas that are not covered by this label. Implementations of C++ exist from some of the most modest microcomputers to the largest supercomputers and for almost all operating systems. Consequently, this book describes the C++ langauge itself without trying to explain a particular implementation, programming environment, or library.
This book presents many examples of classes that, although useful, should be classified as "toys." This style of exposition allows general principles and useful techniques to stand out more clearly than they would in a fully elaborated program, where they would be buried in details. Most of the useful classes presented here, such as linked lists, arrays, character strings, matrices, graphics classes, associative arrays, etc., are available in "bulletproof" and/or "goldplated" versions from a wide variety of commercial and non-commercial sources. Many of these "industrial strength" classes and libraries are actually direct and indirect descendants of the toy versions found here.
This edition provides a greater emphasis on tutorial aspects than did the first edition of this book. However, the presentation is still aimed squarely at experienced programmers and endeavors not to insult their intelligence or experience. The discussion of design issues has been greatly expanded to reflect the demand for information beyond the description of language features and their immediate use. Technical detail and precision have also been increased. The reference manual, in particular, represents many years of work in this direction. The intent has been to provide a book with a depth sufficient to make more than one reading rewarding to most programmers. In other words, this book presents the C++ language, its fundamental principles, and the key techniques needed to apply it. Enjoy!
AcknowledgmentsIn addition to the people mentioned in the acknowledgments section in the preface to the first edition, I would like to thank Al Aho, Steve Buroff, Jim Coplien, Ted Goldstein, Tony Hansen, Peter Juhl, Brian Kernighan, Andrew Koenig, Bill Leggett, Warren Montgomery, Mike Mowbray, Rob Murray, Jonathan Shopiro, Mike Vilot, and Peter Weinberger for commenting on draft chapters of this second edition. Many people influenced the development of C++ from 1985 to 1991. I can mention only a few: Andrew Koenig, Brian Kernighan, Doug McIlroy, and Jonathan Shopiro. Also thanks to the many participants of the "external reviews" and the reference manual drafts and to the people who suffered through the first year of X3J16.
Bjarne Stroustrup
Murray Hill, New Jersey
0201539926P04062001