C++ How to Program, Late Objects Version, 7/e
Harvey M. Deitel and Paul J. Deitel, both from Deitel & Associates, Inc.
© 2011, 992 pp., paper (0-13-216541-4)
- Late-Objects Approach: We briefly introduce the basic concepts and terminology of object technology in Chapter 1—this section can be deferred to the beginning of Chapter 9 by instructors who wish to teach only procedural programming in the early chapters. You’ll develop your first customized classes and objects in Chapter 9.
- Sequential File Processing. We introduce sequential file processing in Chapter 8. This enables instructors to teach these topics in a first course if they wish. We cov- er random-access file processing in Chapter 17.
- VideoNotes. On the book’s Companion Website (www.pearsonhighered.com/ deitel/), we provide extensive VideoNotes that walk you through all of the code examples in Chapters 2–13 and a portion of Chapter 16. The companion website also includes solutions to many of the book’s exercises, bonus chapters, and more (see the Companion Website section later in this Preface).
- Making a Difference Exercises. The dozens of Making a Difference exercises ex- plore complex and challenging social issues, including global warming, popula- tion growth, gender neutrality, computerization of health records, alternative tax plans, hybrid vehicles, accessibility for people with disabilities and more. A com- plete list of the Making a Difference exercises is available at www.deitel.com/ books/cpphtp7LOV/.
- Prefer string Objects to C Strings. C++ offers two types of strings—string class objects (which we use starting in Chapter 6) and C-style, pointer-based strings. We include some early discussions of C strings to give you practice with pointer manipulations, to illustrate dynamic memory allocation with new and delete and to prepare you for working with C strings in the “legacy code” that you’ll encoun- ter in industry. In new development, you should favor string class objects, so we use instances of C++ class string to make programs more robust and eliminate many of the security problems that can be caused by manipulating C strings.
- Prefer vectors to C Arrays. Similarly, C++ offers two types of arrays—vector class objects (which we use starting in Chapter 6) and C-style, pointer-based ar- rays. As appropriate, we use class template vector instead of C arrays throughout the book. However, we begin discussing C arrays in Chapter 6 to prepare you for working with legacy code and to use them as a basis for building your own cus- tomized Array class in Chapter 11, Operator Overloading.
- Titled Programming Exercises. We’ve titled the programming exercises. This helps instructors select assignments for their classes.
- Consistent Use of const. Keyword const is used throughout to encourage better software engineering.
- Function Pointer Exercises. We include several real-world function-pointers exer- cises. These are available at the Companion Website.
- Terminology Sections. We include page numbers for the defining occurrences of all terms in the terminology lists for easy reference.
New Features in the Next C++ Standard
- We discuss four new language features that will be part of the next C++ standard and are already implemented by some of today’s C++ compilers. These include:
- Initializer Lists for User-Defined Types. These enable objects of your own types to be initialized using the same syntax as built-in arrays.
- Range-Based for Statement. A version of the for statement that iterates over all
the elements of an array or container (such as an object of the vector class).
- Lambda Expressions. These enable you to create anonymous functions that can
be passed to other functions as arguments.
- Concepts. These enable template programmers to specify the requirements for
data types that will be used with a particular template. Compilers can then pro-
vide more meaningful error messages when data types do not meet a template’s
- Other features include:
- Game Programming. The computer-game industry’s revenues are already greater
than those of the first-run movie business, creating lots of career opportunities.
Chapter 27, Game Programming with Ogre, introduces game programming and
graphics with the open source Ogre 3D graphics engine. We discuss basic issues
involved in game programming. Then we show how to use Ogre to create a sim-
ple game featuring a play mechanic similar to the classic video game Pong®, orig-
inally developed by Atari. We demonstrate how to create a scene with 3D color
graphics, smoothly animate moving objects, use timers to control animation
speed, detect collisions between objects, add sound, accept keyboard input and
display text output.
- Future of C++. Chapter 23 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 de-
scribes 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. The new
standard is likely to be released in 2010 or 2011. It will include changes to the
core language and many of the libraries in TR1. We overview the Boost libraries
and provide code examples for the “regular expression” and “smart pointer” li-
braries. Regular expressions are used to match specific character patterns in text.
They can be used, for example, to validate data to ensure that it’s in a particular
format, to replace parts of one string with another, or to split a string. Many com-
mon bugs in C and C++ code are related to pointers, a powerful programming
capability you’ll study in Chapter 8, Pointers. Smart pointers help you avoid er-
rors by providing additional functionality to standard pointers.
- 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 dem-
onstrate the flow of control in each of C++’s control statements. We use six types
of UML diagrams in the optional OOD/UML ATM case study
- Compilation and Linking Process for Multiple-Source-File Programs. Chapter 3
includes a detailed diagram and discussion of the compilation and linking process
that produces an executable program.
- Function Call Stack Explanation. 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 au-
tomatic variables of functions are maintained in memory and how a function
knows where to return after it completes execution.
- Tuned Treatment of Inheritance and Polymorphism. Chapters 12–13 have been
carefully tuned using an Employee class hierarchy to make the treatment of inher-
itance and polymorphism clear and accessible for students 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 imple-
ment polymorphism, virtual functions and dynamic binding internally. This
gives students a solid understanding of how these capabilities really work.
- Standard Template Library (STL). This might be one of the most important top-
ics in the book in terms of your appreciation 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 22
introduces the STL and discusses its three key components—containers, iterators
and algorithms. We show that using STL components provides tremendous ex-
pressive power, often reducing many lines of code to a single statement.
- ISO/IEC C++ Standard Compliance. We’ve audited our presentation against the
most recent ISO/IEC C++ standard document.
- Debugger Appendices. We provide two Using the Debugger appendices on the
book’s Companion Website—Appendix H, Using the Visual Studio Debugger,
and Appendix I, Using the GNU C++ Debugger.
- Code Testing on Multiple Platforms. We tested the code examples on various
popular C++ platforms including GNU C++ on Linux and Microsoft and Visual
C++ on Windows. For the most part, the book’s examples port to popular stan-
“Finally, an accurate and complete C++ book that everybody can understand. It will help you achieve a solid knowledge of C++ and of software engineering in general. A ‘must-have.’”
— José Antonio González Seco, Parliament of Andalusia, Spain
“As an instructor, I appreciate the thorough discussion of the C++ language, especially the comprehensive use of code examples and demonstration of best coding practices. For my consulting work I use the Deitel books as my primary reference.”—Dean Mathias, Utah St. U.
“ Chapter 12, Object-Oriented Programming: Inheritance, is so well done. It’s evident that the authors are diligent and focused on quality!”—David Topham, Ohlone College
“Each code example is completely reviewed. This is a critical step for students to learn good programming practices.”—Jack R. Hagemeister, Washington State University
“ The Deitel & Deitel How to Program Series provides a complete basis of fundamental instruction in all core aspects of C++. Comprehensive discussion and examples provide a solid grounding in the construction of C++ programs.”—Peter DePasquale, The College of New Jersey
“The virtual function figure and corresponding text explanation in Chapter 13, Polymorphism, is thorough and truly commendable .”—Gregory Dai, Kernel Development
“Very good, thorough and detailed coverage of exceptions from an object-oriented point of view.”—Dean Mathias, Utah State University
“Code examples are well presented and easy to read...Very impressive that so many resources identified…and mostly free, too!... Excellent introduction to Polymorphism. Clear and accurate.”
—David Topham, Ohlone College
“Aimed at someone new to C++, this is a good introduction to the C++ Standard Template Library (STL) with clear descriptions, examples and plenty of useful tips. The example code is excellent: clean, well documented, with extensive descriptions of what the code is doing and why.”
— Chris Cox, Adobe Systems
“Chapter 20 (Data Structures) is very good. The examples are accessible to CS, IT, software engineering and business students.”—Thomas J. Borrelli, Rochester Institute of Technology
“Chapter 15 provides a solid overview of the major features of the C++ Stream I/O fundamentals The examples are right on point.”—Peter DePasquale, The College of New Jersey
“The Pointers chapter clearly explains a complex subject. The Simpletron exercises are simply brilliant. The Polymorphism chapter explains one of the hardest topics to understand in OOP in a clear manner. Great job! The writing is excellent, the examples are well developed and the exercises are interesting.”— José Antonio González Seco, Parliament of Andalusia, Spain
Comments from the Sixth Edition Reviewers
“An excellent ‘objects first’ coverage of C++ that remains accessible to beginners. 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—the best I have seen.”—Anne B. Horton, Lockheed Martin
“Great coverage of polymorphism and how the compiler implements polymorphism ‘under the hood.’ I wish I had such a clear presentation of data structures when I was a student.”
—Ed James-Beckham, Borland
“A nice introduction to searching and sorting, and Big-O.”—Robert Myers, Florida State Univ.
“Ogre is a free world-class rendering engine that has been used in several commercial games. The Ogre chapter is a great introduction, providing well documented and easy to understand examples that will have you creating your own simple computer games in no time.”
—Casey Borders (Creator of OgreAL), Sensis Corp.
“Getting a new user to the stage of creating a functional and playable Ogre-based computer game in 40 pages is a great achievement.”—Steve Streeting (Creator of Ogre), Torus Knot Software
“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 for the serious student!”—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