Home > Store

Essential C++

Register your product to gain access to bonus material or receive a coupon.

Essential C++


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2000
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 304
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-48518-4
  • ISBN-13: 978-0-201-48518-9

"Readers can pick up this book and become familiar with C++ in a short time. Stan has taken a very broad and complicated topic and reduced it to the essentials that budding C++ programmers need to know to write real programs. His case study is effective and provides a familiar thread throughout the book." --Steve Vinoski, IONA

For the practicing programmer with little time to spare, Essential C++ offers a fast-track to learning and working with C++ on the job. This book is specifically designed to bring you up to speed in a short amount of time. It focuses on the elements of C++ programming that you are most likely to encounter and examines features and techniques that help solve real-world programming challenges.

Essential C++ presents the basics of C++ in the context of procedural, generic, object-based, and object-oriented programming. It is organized around a series of increasingly complex programming problems, and language features are introduced as solutions to these problems. In this way you will not only learn about the functions and structure of C++, but will understand their purpose and rationale.

You will find in-depth coverage of key topics such as:

  • Generic programming and the Standard Template Library (STL)
  • Object-based programming and class design
  • Object-oriented programming and the design of class hierarchies
  • Function and class template design and use
  • Exception handling and Run-Time Type Identification

In addition, an invaluable appendix provides complete solutions to, and detailed explanations of, the programming exercises found at the end of each chapter. A second appendix offers a quick reference handbook for the generic algorithms, providing an example of how each is used.

This concise tutorial will give you a working knowledge of C++ and a firm foundation on which to further your professional expertise.



Source Code

Dowload the Source Code by clicking on the links below:





Click below for Interview related to this title:

Sample Content

Table of Contents


Structure of This Book.

A Note on the Source Code.


Where to Find More Information.

Typographical Conventions.

1. Basic C++ Programming.

How to Write a C++ Program.

Defining and Initializing a Data Object.

Writing Expressions.

Writing Conditional and Loop Statements.

How to Use Arrays and Vectors.

Pointers Allow for Flexibility.

Writing and Reading Files.

2. Procedural Programming.

How to Write a Function.

Invoking a Function.

Providing Default Parameter Values.

Using Local Static Objects.

Declaring a Function Inline.

Providing Overloaded Functions.

Defining and Using Template Functions.

Pointers to Functions Add Flexibility.

Setting Up a Header File.

3. Generic Programming.

The Arithmetic of Pointers.

Making Sense of Iterators.

Operations Common to All Containers.

Using the Sequential Containers.

Using the Generic Algorithms.

How to Design a Generic Algorithm.

Using a Map.

Using a Set.

How to Use Iterator Inserters.

Using the iostream Iterators.

4. Object-Based Programming.

How to Implement a Class.

What are Class Constructors and the Class Destructor?

What are mutable and const?

What is the this Pointer?

Static Class Members.

Building an Iterator Class.

Collaboration Sometimes Requires Friendship.

Implementing a Copy Assignment Operator.

Implementing a Function Object.

Providing Class Instances of the iostream Operators.

Pointers to Class Member Functions.

5. Object-Oriented Programming.

A Tour of Object-Oriented Programming.

Polymorphism without Inheritance.

Defining an Abstract Base Class.

Defining a Derived Class.

Using an Inheritance Hierarchy.

How Abstract Should a Base Class Be?

Initialization, Destruction, and Copy.

Defining a Derived Class Virtual Function.

Run-Time Type Identification.

6. Programming with Templates.

Parameterized Types.

The Template Class Definition.

Handling Template Type Parameters.

Implementing the Template Class.

A Function Template Output Operator.

Constant Expressions and Default Parameters.

Template Parameters as Strategy.

Member Template Functions.

7. Exception Handling.

Throwing an Exception.

Catching an Exception.

Trying for an Exception.

Local Resource Management.

The Standard Exceptions.

Appendix A: Exercise Solutions.

Appendix B: Generic Algorithms Handbook.

Index. 0201485184T04062001


Gosh, but this book is short. I mean, wow. My C++ Primer is 1237 pages counting the index, title, and dedication pages. This one weighs in at just under 300 -- in boxing terms, we're talking bantamweight.

The first question, of course, is how come? Actually, there's a story to that.

I'd been pestering everyone at Disney Feature Animation for a number of years to let me work on a production. I asked directors, management types -- even Mickey, if the truth be told. In part, it was for the glamour, I suppose. Hollywood. The big screen. Also, I hold a Master of Fine Arts as well as my Comp Sci degree, and film work seemed to promise some sort of personal synthesis. What I told management, of course, was that I needed the experience in production in order to provide usable tools. As a compiler writer, I'd always been one of my own main users. It's difficult to get defensive or feel unfairly criticized when you're one of the principal complainers about your software.

The computer effects lead on the Firebird segment of Fantasia 2000 was interested in having me join the production. To kind of try things out, he asked me to write a tool to read the raw Disney camera information for a scene and generate a camera node that could be plugged in to the Houdini animation package. I wrote it in C++, of course. It worked. They liked it. I was invited to come on board.

Once on the production (thanks to Jinko and Chyuan), I was asked to rewrite the tool in Perl. The other TDs, it was explained, weren't heavy-duty programmers but knew Perl, Tcl, and so on. (TD is film industry jargon for technical director. I was the segment's software TD. There was also a lighting TD (hi, Mira) and a model TD (hi, Tim) as well as the actual computer effects animators (hi, Mike, Steve, and Tonya).) And oh, by the way, could I do this quickly, because, gosh, we have a proof of concept test to get out that the directors (hi, Paul and Gaetan) and effects supervisor (hi, Dave) are waiting on to pitch to the then head of Feature Animation (hi, Peter). No emergency, you understand, but ...

This left me in somewhat of a quandary. I can program reasonably quickly in C++ with confidence. Unfortunately, I didn't know Perl. I thought, OK, I'll read a book. But it can't be too big a book, at least not right now. And it had better not tell me too much, although I know I should know everything, only later. After all, this is show biz: The directors need a proof of concept, the artist needs a plug-in to prove the concept, and the producer -- heck, she needs a 48 hour day. I didn't need the best book on Perl -- just the right book to get me going and not steer me too far off the righteous path.

I found that book in Learning Perl by Randal Schwartz. It got me up and running, and it was fun to read. Well, as much as any computer book is fun. It leaves out gobs of good stuff. At the time, though, I didn't need all that stuff -- I needed to get my Perl scripts working.

Eventually, I realized sadly that the third edition of C++ Primer could no longer fill a similar role for someone needing to learn C++. It had just become too big. I think it's a grand book, of course -- particularly with Josee Lajoie coming on board as co-author of the third edition. But it's too comprehensive for this kind of just-in-time C++ language learning. That's why I decided to write this book.

You're probably thinking, but C++ is not Perl. That's correct. And this text is not Learning Perl. It's about learning C++. The real question is, How does one shed almost a thousand pages and still claim to be teaching anything?

  1. Level of detail. In computer graphics, level of detail refers to how sharply an image is rendered. The invading Hun on horseback in the left front corner of the screen needs a face with eyes, hair, five o'clock shadow, clothes, and so on. The Hun way back there -- no, not the rock, silly -- well, we don't render both images with the same care for detail. Similarly, the level of detail in this book is clamped down considerably. C++ Primer, in my opinion, has the most complete but readable discussion of operator overloading in existence (I can say that because Josee was the author). However, it takes 46 pages of discussion and code examples. Here, I take 2 pages.
  2. Core language. When I was editor of the C++ Report, I used to say that half the job of editing the magazine was in deciding what not to put in. The same is true for this text. The text is organized around a series of a programming problems. Language features are introduced to provide a solution to individual problems. I didn't have a problem that multiple or virtual inheritance could solve, so I do not discuss them. To implement an iterator class, however, I had to introduce nested types. Class conversion operators are easy to misuse and are complicated to explain. I therefore chose not to present them. And so on. The choice and order of presentation of language features are always open to criticism. This is my choice and my responsibility.
  3. Number of code examples. C++ Primer has hundreds of pages of code that we step through in detail, including an object-oriented Text Query system and about a half-dozen fully implemented classes. Although this text is code-driven, the set of code examples is simply not as rich as that of C++ Primer. To help compensate, solutions to all the program exercises are provided in Appendix A. As my editor, Deborah Lafferty, said, ''If you are trying to teach something quickly, it is helpful to have the answers at your fingertips to reinforce the learning."

Structure of This Book

The text consists of seven chapters and two appendixes. Chapter 1 provides a description of the predefined language in the context of writing a small interactive program. It covers the built-in data types, the predefined operators, the vector and string library classes, the conditional and looping statements, and the iostream library for input and output. I introduce the vector and string classes in this chapter because I encourage their use over the built-in array and C-style character string.

Chapter 2 explains how to design and use a function and walks through the many flavors of functions supported in C++: inline, overloaded, and template functions as well as pointers to functions.

Chapter 3 covers what is commonly referred to as the Standard Template Library (STL): a collection of container classes, such as a vector, list, set, and map, and generic algorithms to operate on those containers, such as sort(), copy(), and merge(). Appendix B presents an alphabetical listing of the most commonly used generic algorithms and provides an example of how each one is used.

As a C++ programmer, your primary activity is the delivery of classes and object-oriented class hierarchies. Chapter 4 walks through the design and use of the C++ class facility to create data types specific to your application domain. For example, at Dreamworks Animation, where I do some consulting work, we design classes to do four-channel compositing of images and so on. Chapter 5 explains how to extend class design to support families of related classes in object-oriented class hierarchies. Rather than design eight independent image compositing classes, for example, we define a compositing hierarchy using inheritance and dynamic binding.

Class templates are the topic of Chapter 6. A class template is a kind of prescription for creating a class in which one or more types or values are parameterized. A vector class, for example, may parameterize the type of element it contains. A buffer class may parameterize not only the type of element it holds but also the size of its buffer. The chapter is driven by the implementation of a binary tree template class.

Finally, Chapter 7 illustrates how to use the C++ exception handling facility and fit it into the existing standard library exception class hierarchy. Appendix A provides solutions to the programming exercises. Appendix B provides a program example and discussion of the most frequently used generic algorithm.

A Note on the Source Code

The full source code of the programs developed within the text as well as the solutions to the exercises is available on-line for downloading both at the Addison-Wesley Longman web site and on my home page (www.objectwrite.com). All the code has been executed under both Visual C++ 5.0 using the Intel C++ compiler and Visual C++ 6.0 using the Microsoft C++ compiler. You may need to modify the code slightly to have it compile on your system. If you make any modifications, send me a list of them (slippman@objectwrite.com) and I will post them, along with your name, in a modifications file attached to the solutions code. (Note that the full source code is not displayed within the text itself.)


Special thanks go to Josee Lajoie, coauthor of C++ Primer, 3rd Edition. She has been a wonderful support both because of her insightful comments on the various drafts of this text and because of her unfailing encouragement. I also offer special thanks to Dave Slayton for going through both the text and the code examples with a razor sharp green pencil, and to Steve Vinoski for his compassionate but firm comments on the drafts of this text.

Special thanks also go to the Addison Wesley editorial team: Deborah Lafferty, who, as editor, supported this project from the beginning, Betsy Hardinger, who, as copyeditor, contributed greatly to the readability of the text, and John Fuller, who, as production manager, shepherded us from manuscript to bound text.

During the writing of this text, I worked as an independent consultant, multiplexing between Essential C++ and a set of (reasonably) understanding clients. I'd like to thank Colin Lipworth, Edwin Leonard, and Kenneth Meyer for their patience and good faith.

Where to Find More Information

From a completely biased point of view, the two best one-volume introductions to C++ are Lippman and Lajoie's C++ Primer, 3rd Edition and Stroustrup's The C++ Programming Language, both in their third edition. Throughout the text I refer you to one or both of the texts for more in-depth information. The following books are cited in the text. (A more extensive bibliography can be found in both C++ Primer and The C++ Programming Language.)

98LIPPMAN Lippman, Stanley, and Josee Lajoie, C++ Primer, 3rd Edition, Addison Wesley Longman, Inc., Reading, MA (1998) ISBN 0-201-82470-1.
96LIPPMAN Lippman, Stanley, Inside the C++ Object Model, Addison Wesley Longman, Inc., Reading, MA (1996) ISBN 0-201-83454-5.
96bLIPPMAN Lippman, Stanley, Editor, C++ Gems, a SIGS Books imprint, Cambridge University Press, Cambridge, England (1996) ISBN 0-13570581-9.
97STROUSTRUP Stroustrup, Bjarne, The C++ Programming Language, Addison Wesley Longman, Inc., Reading, MA (1997) ISBN 0-201-88954-4.
99SUTTER Sutter, Herb, Exceptional C++, Addison Wesley Longman, Inc., Reading, MA (2000) ISBN 0-201-61562-2.

Typographical Conventions

The text of the book is set in 10.5 pt. Palatino. Program text and language keywords appear in 8.5 pt. Lucida. Functions are identified by following their name with the C++ function call operator (()). Thus, for example, foo represents a program object, and bar() represents a program function. Class names are set in Palatino.


More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020