C++ for Programmers

3.95 avg rating
( 20 ratings by Goodreads )
9780137001309: C++ for Programmers


  • Classes, Objects, Encapsulation, Inheritance, Polymorphism
  • Integrated OOP Case Studies: Time, GradeBook, Employee
  • Industrial-Strength, 95-Page OOD/UML® 2 ATM Case Study
  • Standard Template Library (STL): Containers, Iterators and Algorithms
  • I/O, Types, Control Statements, Functions
  • Arrays, Vectors, Pointers, References
  • String Class, C-Style Strings
  • Operator Overloading, Templates
  • Exception Handling, Files
  • Bit and Character Manipulation
  • Boost Libraries and the Future of C++
  • GNU™ and Visual C++® Debuggers
  • And more...
  • For information on Deitel® Dive-Into® Series corporate training courses offered at customer sites worldwide (or write to deitel@deitel.com)
  • Download code examples
  • Check out the growing list of programming, Web 2.0 and software-related Resource Centers
  • To receive updates for this book, subscribe to the free DEITEL® BUZZ ONLINE e-mail newsletter at www.deitel.com/newsletter/subscribe.html
  • Read archived issues of the DEITEL® BUZZ ONLINE
The professional programmer’s DEITEL® guide to C++ and object-oriented application development

Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching programming and explores the C++ language and C++ Standard Libraries in depth. The book presents the concepts in the context of fully tested programs, complete with syntax shading, code highlighting, code walkthroughs and program outputs. The book features 240 C++ applications with over 15,000 lines of proven C++ code, and hundreds of tips that will help you build robust applications.

Start with an introduction to C++ using an early classes and objects approach, then rapidly move on to more advanced topics, including templates, exception handling, the Standard Template Library (STL) and selected features from the Boost libraries. You’ll enjoy the Deitels’ classic treatment of object-oriented programming and the OOD/UML® 2 ATM case study, including a complete C++ implementation. When you’re finished, you’ll have everything you need to build object-oriented C++ applications.

The DEITEL® Developer Series is designed for practicing programmers. The series presents focused treatments of emerging technologies, including C++, .NET, Java™, web services, Internet and web development and more. 
“An excellent ‘objects first’ coverage of C++. The example-driven presentation is enriched by the optional UML case study that contextualizes the material in an ongoing software engineering project.” —Gavin Osborne, Saskatchewan Institute of Applied Science and Technology

“Introducing the UML early on is a great idea.” —Raymond Stephenson, Microsoft

“Good use of diagrams, especially of the activation call stack and recursive functions.” —Amar Raheja, California State Polytechnic University, Pomona

“Terrific discussion of pointers—probably the best I have seen.” —Anne B. Horton, Lockheed Martin

“Great coverage of polymorphism and how the compiler implements polymorphism ‘under the hood.’” —Ed James-Beckham, Borland

“The Boost/C++0x chapter will get you up and running quickly with the memory management and regular expression libraries, plus whet your appetite for new C++ features being standardized.” —Ed Brey, Kohler Co.

“Excellent introduction to the Standard Template Library (STL). The best book on C++ programming!”  —Richard Albright, Goldey-Beacom College

“Just when you think you are focused on learning one topic, suddenly you discover you’ve learned more than you expected.” —Chad Willwerth, University of Washington, Tacoma

“The most thorough C++ treatment I’ve seen. Replete with real-world case studies covering the full software development lifecycle. Code examples are extraordinary!” —Terrell Hull, Logicalis Integration Solutions/

"synopsis" may belong to another edition of this title.

About the Author:

Paul J. Deitel and Dr. Harvey M. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized programming languages authoring, corporate-training and Internet business development organization. The Deitels have written many international best-selling programming-language professional books and textbooks that millions of people worldwide have used to master C++, C, Java™, C#, Visual Basic®, Visual C++® XML, Perl, Python, and Internet and web programming.  

Excerpt. Reprinted by permission. All rights reserved.:



“The chief merit of language is clearness ...”

Welcome to C++ for Programmers! At Deitel & Associates, we write programming language professional books and textbooks for publication by Prentice Hall, deliver programming languages corporate training courses at organizations worldwide and develop Internet businesses. This book is intended for programmers who do not yet know C++, and may or may not know object-oriented programming.

Features of C++ for Programmers

The Tour of the Book section of this Preface will give you a sense of C++ for Programmers’ coverage of C++ and object-oriented programming. Here’s some key features of the book:

  • Early Classes and Objects Approach. We present object-oriented programming, where appropriate, from the start and throughout the text.
  • Integrated Case Studies. We develop the GradeBook class in Chapters 3–7, the Time class in several sections of Chapters 9–10, the Employee class in Chapters 12–13, and the optional OOD/UML ATM case study in Chapters 1– 7, 9, 13 and Appendix E.
  • Unified Modeling Language™ 2 (UML 2). The Unified Modeling Language (UML) has become the preferred graphical modeling language for designers of object-oriented systems. We use UML class diagrams to visually represent classes and their inheritance relationships, and we use UML activity diagrams to demonstrate the flow of control in each of C++’s control statements. We emphasize the UML in the optional OOD/UML ATM case study
  • Optional OOD/UML ATM Case Study. We introduce a concise subset of the UML 2, then guide you through a first design experience intended for the novice object-oriented designer/programmer. The case study was reviewed by a distinguished team of OOD/UML industry professionals and academics. The case study is not an exercise; rather, it’s a fully developed end-to-end learning experience that concludes with a detailed walkthrough of the complete 877-line C++ code implementation. We take a detailed tour of the nine sections of this case study later in the Preface.
  • Function Call Stack Explanation. In Chapter 6, we provide a detailed discussion (with illustrations) of the function call stack and activation records to explain how C++ is able to keep track of which function is currently executing, how automatic variables of functions are maintained in memory and how a function knows where to return after it completes execution.
  • Class string. We use class string instead of C-like pointer-based char * strings for most string manipulations throughout the book. We include discussions of char * strings in Chapters 8, 10, 11 and 19 to give you practice with pointer manipulations, to illustrate dynamic memory allocation with new and delete, to build our own String class, and to prepare you for working with char * strings in C and C++ legacy code.
  • Class Template vector. We use class template vector instead of C-like pointer-based array manipulations throughout the book. However, we begin by discussing C-like pointer-based arrays in Chapter 7 to prepare you for working with C and C++ legacy code and to use as a basis for building our own customized Array class in Chapter 11.
  • Treatment of Inheritance and Polymorphism. Chapters 12–13 include an Employee class hierarchy that makes the treatment of inheritance and polymorphism clear and accessible for programmers who are new to OOP.
  • Discussion and Illustration of How Polymorphism Works “Under the Hood.” Chapter 13 contains a detailed diagram and explanation of how C++ can implement polymorphism, virtual functions and dynamic binding internally. This gives you a solid understanding of how these capabilities really work. More importantly, it helps you appreciate the overhead of polymorphism—in terms of additional memory consumption and processor time. This helps you determine when to use polymorphism and when to avoid it.
  • Standard Template Library (STL). This might be one of the most important topics in the book in terms of software reuse. The STL defines powerful, template-based, reusable components that implement many common data structures and algorithms used to process those data structures. Chapter 20 introduces the STL and discusses its three key components—containers, iterators and algorithms. Using STL components provides tremendous expressive power, often reducing many lines of non-STL code to a single statement.
  • ISO/IEC C++ Standard Compliance. We have audited our presentation against the most recent ISO/IEC C++ standard document for completeness and accuracy. Note: A PDF copy of the C++ standard (document number INCITS/ISO/ IEC 14882-2003) can be purchased at webstore.ansi.org/ansidocstore/ default.asp.
  • Future of C++. In Chapter 21, which considers the future of C++, we introduce the Boost C++ Libraries, Technical Report 1 (TR1) and C++0x. The free Boost open source libraries are created by members of the C++ community. Technical Report 1 describes the proposed changes to the C++ Standard Library, many of which are based on current Boost libraries. The C++ Standards Committee is revising the C++ Standard. The main goals for the new standard are to make C++ easier to learn, improve library building capabilities, and increase compatibility with the C programming language. The last standard was published in 1998. Work on the new standard, currently referred to as C++0x, began in 2003. The new standard is likely to be released in 2009. It will include changes to the core language and, most likely, many of the libraries in TR1. We overview the TR1 libraries and provide code examples for the “regular expression” and “smart pointer” libraries.
  • Debugger Appendices. We include two Using the Debugger appendices— Appendix G, Using the Visual Studio Debugger, and Appendix H, Using the GNU C++ Debugger.
  • Code Testing on Multiple Platforms. We tested the code examples on various popular C++ platforms. For the most part, the book’s examples port easily to standard-compliant compilers.
  • Errors and Warnings Shown for Multiple Platforms. For programs that intentionally contain errors to illustrate a key concept, we show the error messages that result on several popular platforms.

All of this was carefully reviewed by distinguished industry developers and academics. We believe that this book will provide you with an informative, interesting, challenging and entertaining C++ educational experience.

As you read this book, if you have questions, send an e-mail to deitel@deitel.com; we’ll respond promptly. For updates on this book and the status of all supporting C++ software, and for the latest news on all Deitel publications and services, visit http://www.deitel.com. Sign up at http://www.deitel.com/newsletter/subscribe.html for the free Deitel¨ Buzz Online e-mail newsletter and check out our growing list of C++ and related Resource Centers at http://www.deitel.com/ResourceCenters.html. Each week we announce our latest Resource Centers in the newsletter.

Learning Features

C++ for Programmers contains a rich collection of examples. The book concentrates on the principles of good software engineering and stresses program clarity. We teach by example. We are educators who teach programming languages in industry classrooms worldwide. The Deitels have taught courses at all levels to government, industry, military and academic clients of Deitel & Associates.

Live-Code Approach. C++ for Programmers is loaded with “live-code” examples—by this we mean that each new concept is presented in the context of a complete working C++ application that is immediately followed by one or more actual executions showing the program’s inputs and outputs.

Syntax Shading. We syntax-shade all the C++ code, similar to the way most C++ integrated development environments (IDEs) and code editors syntax-color code. This greatly improves code readability—an especially important goal, given that this book contains over 15,500 lines of code. Our syntax-shading conventions are as follows:

comments appear in italic keywords appear in bold italic errors and ASP.NET script delimiters appear in bold black constants and literal values appear in bold gray all other code appears in plain black

Code Highlighting. We place white rectangles around the key code segments in each program.

Using Fonts for Emphasis. We place the key terms and the index’s page reference for each defining occurrence in bold italic text for easier reference. We emphasize on-screen components in the bold Helvetica font (e.g., the File menu) and emphasize C++ program text in the Lucida font (e.g., int x = 5).

Web Access. All of the source-code examples for C++ for Programmers are available for download from http://www.deitel.com/books/cppfp/.

Objectives. Each chapter begins with a statement of objectives. This lets you know what to expect and gives you an opportunity, after reading the chapter, to determine if you’ve met the objectives.

Quotations. The learning objectives are followed by quotations. Some are humorous; some are philosophical; others offer interesting insights. We hope that you enjoy relating the quotations to the chapter material.

Outline. The chapter outlines help you approach the material in a top-down fashion, so you can anticipate what is to come and set a comfortable and effective learning pace.

Illustrations/Figures. Abundant charts, tables, line drawings, programs and program output are included. We model the flow of control in control statements with UML activity diagrams. UML class diagrams model the fields, constructors and methods of classes. We make extensive use of six major UML diagram types in the optional OOD/UML 2 ATM case study.

Programming Tips. We include programming tips to help you focus on important aspects of program development. These tips and practices represent the best we’ve gleaned from a combined seven decades of programming experience—they provide a basis on which to build good software.

Good Programming Practice - Good Programming Practices call attention to techniques that will help you produce programs that are clearer, more understandable and more maintainable.

Common Programming Error - Pointing out these Common Programming Errors reduces the likelihood that you’ll make the same mistakes.

Error-Prevention Tip - These tips contain suggestions for exposing bugs and removing them from your programs; many describe aspects of C++ that prevent bugs from getting into programs in the first place.

Performance Tip - These tips highlight opportunities for making your programs run faster or minimizing the amount of memory that they occupy.

Portability Tip - We include Portability Tips to help you write code that will run on a variety of platforms and to explain how C++ achieves its high degree of portability.

Software Engineering Observation - The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems.

Wrap-Up Section. Each of the chapters ends with a brief “wrap-up” section that recaps the chapter content and transitions to the next chapter.

Thousands of Index Entries. We’ve included an extensive index which is especially useful when you use the book as a reference.

“Double Indexing” of C++ Live-Code Examples. For every source-code program in the book, we index the figure caption both alphabetically and as a subindex item under “Examples.” This makes it easier to find examples using particular features.

Tour of the Book

You’ll now take a tour of the C++ capabilities you’ll study in C++ for Programmers. Figure 1 illustrates the dependencies among the chapters. We recommend studying the topics in the order indicated by the arrows, though other orders are possible.

Chapter 1, Introduction, discusses the origin of the C++ programming language, and introduces a typical C++ programming environment. We walk through a “test drive” of a typical C++ application on the Windows and Linux platforms. We also introduce basic object technology concepts and terminology, and the Unified Modeling Language.

Chapter 2, Introduction to C++ Programming, provides a lightweight introduction to programming applications in C++. The programs in this chapter illustrate how to display data on the screen, obtain data from the keyboard, make decisions and perform arithmetic operations.

Chapter 3, Introduction to Classes and Objects, provides a friendly early introduction to classes and objects. We introduce classes, objects, member functions, constructors and data members using a series of simple real-world examples. We develop a well-engineered framework for organizing object-oriented programs in C++. We motivate the notion of classes with a simple example. Then we present a carefully paced sequence of seven complete working programs to demonstrate creating and using your own classes. These examples begin our integrated case study on developing a grade-book class that an instructor can use to maintain student test scores. This case study is enhanced over the next several chapters, culminating with the version presented in Chapter 7. The GradeBook class case study describes how to define a class and how to use it to create an object. The case study discusses how to declare and define member functions to implement the class’s behaviors, how to declare data members to implement the class’s attributes and how to call an object’s member functions to make them perform their tasks. We introduce C++ Standard Library class string and create string objects to store the name of the course that a GradeBook object represents. We explain the differences between data members of a class and local variables of a function, and how to use a constructor to ensure that an object’s data is initialized when the object is created. We show how to promote software reusability by separating a class definition from the client code (e.g., function main) that uses the class. We also introduce another fundamental principle of good software engineering—separating interface from implementation.

Fig. 1 C++ for Programmers chapter dependency chart.

Chapter 4, Control Statements: Part 1, focuses on the program-development process involved in creating useful classes. The chapter introduces some cont...

"About this title" may belong to another edition of this title.

Top Search Results from the AbeBooks Marketplace


Deitel, Paul J.Deitel, Harvey M.
Published by Prentice Hall
ISBN 10: 0137001304 ISBN 13: 9780137001309
New Quantity Available: > 20
(Avenel, NJ, U.S.A.)

Book Description Prentice Hall. Book Condition: New. Brand New. Bookseller Inventory # 0137001304

More Information About This Seller | Ask Bookseller a Question

Buy New
Convert Currency

Add to Basket

Shipping: 2.65
Within U.S.A.
Destination, Rates & Speeds


Deitel, Paul, Deitel, Harvey M.
Published by Prentice Hall (2009)
ISBN 10: 0137001304 ISBN 13: 9780137001309
New Paperback Quantity Available: 2
Murray Media
(North Miami Beach, FL, U.S.A.)

Book Description Prentice Hall, 2009. Paperback. Book Condition: New. Never used!. Bookseller Inventory # P110137001304

More Information About This Seller | Ask Bookseller a Question

Buy New
Convert Currency

Add to Basket

Shipping: 1.51
Within U.S.A.
Destination, Rates & Speeds


Paul J. Deitel, Harvey M. Deitel
Published by Prentice Hall (2009)
ISBN 10: 0137001304 ISBN 13: 9780137001309
New Paperback Quantity Available: 1

Book Description Prentice Hall, 2009. Paperback. Book Condition: New. 1. Bookseller Inventory # DADAX0137001304

More Information About This Seller | Ask Bookseller a Question

Buy New
Convert Currency

Add to Basket

Shipping: 3.03
Within U.S.A.
Destination, Rates & Speeds


Paul Deitel; Harvey M. Deitel
Published by Prentice Hall (2009)
ISBN 10: 0137001304 ISBN 13: 9780137001309
New Softcover Quantity Available: > 20
(Sanford, NC, U.S.A.)

Book Description Prentice Hall, 2009. Book Condition: New. Brand new! Please provide a physical shipping address. Bookseller Inventory # 9780137001309

More Information About This Seller | Ask Bookseller a Question

Buy New
Convert Currency

Add to Basket

Shipping: 2.28
Within U.S.A.
Destination, Rates & Speeds


Deitel, Harvey M./ Deitel, Paul J.
Published by Prentice Hall Ptr (2009)
ISBN 10: 0137001304 ISBN 13: 9780137001309
New Paperback Quantity Available: 1
Revaluation Books
(Exeter, United Kingdom)

Book Description Prentice Hall Ptr, 2009. Paperback. Book Condition: Brand New. 1st edition. 1000 pages. 9.00x7.00x2.00 inches. In Stock. Bookseller Inventory # 0137001304

More Information About This Seller | Ask Bookseller a Question

Buy New
Convert Currency

Add to Basket

Shipping: 6
From United Kingdom to U.S.A.
Destination, Rates & Speeds