C++ How to Program

Prentice Hall
Paul J. Deitel / Harvey Deitel  
Total pages
October 2010
Related Titles


For Introduction to Programming (CS1) and other more intermediate courses covering programming in C++. Also appropriate as a supplement for upper-level courses where the instructor uses a book as a reference for the C++ language.

This best-selling comprehensive text is aimed at readers with little or no programming experience. It teaches programming by presenting the concepts in the context of full working programs and takes a late objects approach. The authors emphasize achieving program clarity through structured and object-oriented programming, software reuse and component-oriented software construction. The Seventh Edition encourages students to connect computers to the community, using the Internet to solve problems and make a difference in our world. All content has been carefully fine-tuned in response to a team of distinguished academic and industry reviewers.

The Late Objects Version delays coverage of class development until Chapter 9, presenting control statements, functions, arrays and pointers in a non-object-oriented, procedural programming context.


  • Full-color program listings include highlighting of the new features presented and syntax coloring of code to help readers better interpret the code.
  • Signature “Live Code™ Approach” – Language features are presented in the context of complete working programs.
    – Features thousands of lines of code in hundreds of complete working programs.
    – Enables students to confirm that programs run as expected.
    – Students can also manipulate the code from the book's website www.pearsonhighered.com/deitelinternational or from the author's Web site.
  • Outstanding, consistent and applied pedagogy provides hundreds of valuable programming tips and facilitates learning.
    – Icons throughout the text identify hundreds of Software Engineering Observations; Good Programming Practices; Common Programming Errors; Portability Tips; Performance Tips, Testing and Debugging Tips, and Look-and-Feel Observations.
  • Late objects approach.
  • “Making a Difference” exercise sets encourage students to associate computers and the Internet with solving problems that really matter to individuals, communities, countries and the world.
    – These new exercises encourage students to think for themselves as they explore complex social issues and increase awareness of important issues the world is facing.
    – Many of the new exercises require students to conduct research on the web and weave the results into their problem-solving process..
  • Optional automated teller machine (ATM) case study teaches the fundamentals of software engineering and object-oriented design with the UMLTM 2.0
  • Integrated case studies throughout the book including the Time class; the Employee class and the GradeBook class
  • An access code to the companion website: www.pearsonhighered.com/deitelinternational is available free when packaged with a new text. The Companion Website includes VideoNotes for most of the code examples, solutions to many of the book's exercises, bonus chapters, and a lab manual.
  • VideoNotes are step-by-step video tutorials specifically designed to enhance the programming concepts presented in Deitel, C++ How to Program: Late Objects, 7e. Students can view the entire problem-solving process outside of the classroom—when they need help the most. VideoNotes are available with the purchase of a new copy of select titles. Go to www.pearsonhighered.com/videonotes for a brief VideoNotes demo.

New to this Edition

The Late Objects Version delays coverage of class development until Chapter 9, presenting control statements, functions, arrays and pointers in a non-object-oriented, procedural programming context.

  • Fundamental topics (control statements, functions, arrays and pointers) are covered near the beginning of the book and before object-oriented programming.
  • Emphasizes top-down, stepwise refinement with pseudocode.
  • Late-Objects Approach. The authors 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. Students will develop their first customized classes and objects in Chapter 9. Objects can be covered near the end of the CS1 course or at the beginning of CS2.
  • Sequential File Processing. Sequential file processing in Chapter 8. This enables instructors to teach these topics in a first course if they wish. Random-access file processing is covered in Chapter 17.
  • VideoNotes. On the book's Companion Website (www.pearsonhighered.com/deitelinternational), extensive VideoNotes 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.
  • Making a Difference Exercises. The dozens of Making a Difference exercises explore complex and challenging social issues, including global warming, population growth, gender neutrality, computerization of health records, alternative tax plans, hybrid vehicles, accessibility for people with disabilities and more. A complete 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 are used starting in Chapter 6) and C-style, pointer-based strings. Some early discussions of C strings are included to give practice with pointer manipulations, to illustrate dynamicmemory allocation with new and delete and to prepare students for working with Cstrings in the “legacy code” that they'll encounter in industry. In new development, students should favor string class objects, so instances of C++ class string are used 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 are used starting in Chapter 6) and C-style, pointer-based arrays. As appropriate, class template vector is used instead of C arrays throughout the book. However, the authors begin discussing C arrays in Chapter 6 to prepare students for working with legacy code and to use them as a basis for building their own customized Array class in Chapter 11, Operator Overloading.
  • Titled Programming Exercises. Programming exercises are titled to help instructors select assignments for their classes.
  • Consistent Use of const. Keyword const is used throughout to encourage better software engineering.
  • Function Pointer Exercises. Several real-world function-pointers exercises are available at the Companion Website.
  • Terminology Sections. Page numbers are included for the defining occurrences of all terms in the terminology lists for easy reference.

Table of Contents

1. Introduction to Computers, the Internet and the World Wide Web
2. Introduction to C++ Programming
3. Control Statements: Part 1
4. Control Statements: Part 2
5. Functions and an Introduction to Recursion
6. Arrays and Vectors
7. Pointers
8. Sequential-Access Files
9. Classes
10. Classes: A Deeper Look
11. Operator Overloading
12. Object-Oriented Programming: Inheritance
13. Object-Oriented Programming: Polymorphism
14. Templates
15. Stream Input/Output
16. Exception Handling
17. Random-Access Files
18. Class String and String Stream Processing
19. Searching and Sorting
20. Data Structures
21. Standard Template Library (STL)
Appendix A. Operator Precedence and Associativity
Appendix B. ASCII Character Set
Appendix C. Fundamental Types

Chapters 22-27 and Appendices D-I are PDF documents posted online at the book's Companion Website (located at www.pearsonhighered.com/deitel).

Chapters on the Web
22. Bits, Characters, C Strings and structs
23. Boost Libraries, Technical Report 1 and C++0x
24. Other Topics
25. ATM Case Study, Part 1: Object-Oriented Design with the UML
26. ATM Case Study, Part 2: Implementing an Object-Oriented Design
27. Game Programming with Ogre

Appendices on the Web
D. Number Systems
E. Preprocessor
F. C Legacy Code Topics
G. UML 2: Additional Diagram Types
H. Using the Visual Studio Debugger
I. Using the GNU C++ Debugger

Back Cover

C++ Programming

More Comments Inside Back Cover
"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 demonstrations of best coding practices. For my consulting work I use the Deitel books as my primary reference."-Dean Mathias, Utah State University

Since the 1990s, over a million students and professionals have learned programming and software development with Deitel® textbooks, professional books and multimedia publications. This Late Objects Version of C++ How to Program, 7/e provides clear and thorough coverage of C++ programming. It's appropriate for one-semester procedural programming courses with little or no objects coverage, one semester courses that begin with procedural programming then proceed to object-oriented programming and possibly a selection of upper-level C++ topics, and second courses in intermediate-level

C++ How to Program, Late Objects Version, 7/e includes:

• Procedural programming from the start: The first eight chapters provide rich coverage of C++ fundamentals, including two full chapters on control statements.
• Objects and classes in the middle: The next chapters present object technology concepts, including classes, inheritance, polymorphism, operator overloading, templates and exception handling.
• Intermediate-level topics: The book includes substantial coverage of strings, files, streams, searching and sorting, data structures and the Standard Template Library. Additional chapters on game programming, an optional OOD ATM case study, the Boost C++ Libraries, the future of C++ and more, are available online.

Also by Paul & Harvey Deitel
C++ How to Program, 7/e
ISBN: 0-13-611726-0
Introduces classes and objects in Chapter 3, before control statements, functions and arrays. It's suitable for those who prefer an early objects approach to C++ programming.

Contact the authors at: deitel@deitel.com
Register for the DEITEL® BUZZ ONLINE newsletter: www.deitel.com/newsletter/subscribe.html
For information on Deitel® onsite training delivered worldwide, visit www.deitel.com/training/
Follow us on Twitter® @deitel and Facebook® at www.deitel.com/deitelfan/


Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of MIT's Sloan School of Management, where he studied Information Technology. He holds the Java Certified Programmer and Java Certified Developer certifications, and has been designated by Sun Microsystems as a Java Champion. Through Deitel & Associates, Inc., he has delivered Java, C, C++, C# and Visual Basic courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems, Nortel Networks, Puma, iRobot, Invensys and many more. He has also lectured on Java and C++ for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling programming language textbook authors.

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 45 years of academic and industry experience in the computer field. Dr. Deitel earned B.S. and M.S. degrees from the MIT and a Ph.D. from Boston University. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.

Reader Review(s)

Comments from the C++ How to Program, 6/e and 7/e Reviewers

"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 demonstrations of best coding practices. For my consulting work I use the Deitel books as my primary reference." - Dean Mathias, Utah State University

"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

"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

"Accessible to beginners. The example-driven presentation is enriched by the optional UML case study that contextualizes the material in a software engineering project." - Gavin Osborne, Saskatchewan Institute of Applied Science and Technology

"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

"Code examples are well presented and easy to read. . . Very impressive that so many resources are identified. . . and mostly free, too!" - David Topham, Ohlone College

"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

"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

"Very good, thorough and detailed coverage of exceptions from an object-oriented point of view." - Dean Mathias, Utah State University

"I wish I'd had such a clear presentation of data structures when I was a student. Great coverage of polymorphism and how the compiler implements polymorphism 'under the hood.'" - Ed James-Beckham, Borland

"Replete with real-world case studies covering the full software development lifecycle. Code examples are extraordinary!" - Terrell Hull, Logicalis Integration Solutions

"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

"A nice introduction to searching and sorting, and Big-O." - Robert Myers, Florida State University

"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

"The best book on C++ programming for the serious student! Excellent introduction to the Standard Template Library (STL)." - Richard Albright, Goldey-Beacom College

"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.

"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.

Instructor Resources