You are previewing The Waite Group's C++ Primer Plus, Third Edition.
O'Reilly logo
The Waite Group's C++ Primer Plus, Third Edition

Book Description

This book includes coverage of the Standard Template Library, one of the most significant additions to C++, and a topic you will have to master to be competitive in the C++ market. All the listings and examples use the new std namespace and in some of the more difficult areas, such as inheritance, the examples have been made more lucid and straight-forward. Also included is coverage of the latest object-oriented programming techniques such as UML, CRC cards and design patterns. TWG's C++ Primer Plus, Third edition makes understanding and experimenting with important object-oriented programming concepts like classes, inheritance, templates, and exceptions both interesting and manageable. It shows how to handle input and output, make programs perform repetitive tasks, manipulate data, hide information, use functions, and build flexible, easily modifiable programs.

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. Tell Us What You Think!
  5. Preface to the Third Edition
  6. Preface to the Second Edition
  7. Preface to the First Edition
  8. Note to Instructors
  9. How This Book Is Organized
  10. GETTING STARTED
    1. Learning C++
    2. A Little History
    3. Portability and Standards
    4. The Mechanics of Creating a Program
    5. Conventions Used in This Book
    6. Our System
  11. SETTING OUT TO C++
    1. C++ Initiation
    2. More About C++ Statements
    3. More C++ Statements
    4. Functions
    5. Summary
    6. Review Questions
    7. Programming Exercises
  12. DEALING WITH DATA
    1. Simple Variables
    2. Unsigned Types
    3. The const Qualifier
    4. Floating-Point Numbers
    5. C++ Arithmetic Operators
    6. Summary
    7. Review Questions
    8. Programming Exercises
  13. DERIVED TYPES
    1. Introducing Arrays
    2. Strings
    3. Introducing Structures
    4. Unions
    5. Enumerations
    6. Pointers and the Free Store
    7. Summary
    8. Review Questions
    9. Programming Exercises
  14. LOOPS AND RELATIONAL EXPRESSIONS
    1. Introducing the for Loop
    2. Relational Expressions
    3. The while Loop
    4. The do while Loop
    5. Loops and Text Input
    6. Nested Loops and Two-Dimensional Arrays
    7. Summary
    8. Review Questions
    9. Programming Exercises
  15. BRANCHING STATEMENTS AND LOGICAL OPERATORS
    1. The if Statement
    2. Logical Expressions
    3. The cctype Library of Character Functions
    4. The ?: Operator
    5. The switch Statement
    6. The break and continue Statements
    7. Number-Reading Loops
    8. Summary
    9. Review Questions
    10. Programming Exercises
  16. FUNCTIONS—C++'S PROGRAMMING MODULES
    1. Function Review
    2. Function Arguments and Passing by Value
    3. Functions and Arrays
    4. Functions and C-Style Strings
    5. Functions and Structures
    6. Recursion
    7. Pointers to Functions
    8. Summary
    9. Review Questions
    10. Programming Exercises
  17. ADVENTURES IN FUNCTIONS
    1. Inline Functions
    2. Reference Variables
    3. Default Arguments
    4. Function Polymorphism (Function Overloading)
    5. Function Templates
    6. Separate Compilation
    7. Storage Classes, Scope, and Linkage
    8. Namespaces
    9. Summary
    10. Review Questions
    11. Programming Exercises
  18. Objects and Classes
    1. Procedural and Object-Oriented Programming
    2. Abstraction and Classes
    3. Class Constructors and Destructors
    4. Knowing Your Objects: The this Pointer
    5. An Array of Objects
    6. Class Scope
    7. An Abstract Data Type
    8. Summary
    9. Review Questions
    10. Programming Exercises
  19. WORKING WITH CLASSES
    1. Operator Overloading
    2. Time on Our Hands
    3. Introducing Friends
    4. Overloaded Operators: Member Versus Non-Member Functions
    5. More Overloading: A Vector Class
    6. Automatic Conversions and Type Casts for Classes
    7. Summary
    8. Review Questions
    9. Programming Exercises
  20. CLASSES AND DYNAMIC MEMORY ALLOCATION
    1. Dynamic Memory and Classes
    2. Trouble in String City
    3. A Queue Simulation
    4. Summary
    5. Review Questions
    6. Programming Exercises
  21. CLASS INHERITANCE
    1. Beginning with a Simple Base Class
    2. Inheritance—An Is-a Relationship
    3. Virtual Member Functions
    4. Inheritance and Assignment
    5. Abstract Base Classes
    6. Class Design Review
    7. Summary
    8. Review Questions
    9. Exercises
  22. REUSING CODE IN C++
    1. Classes with Object Members
    2. Private Inheritance
    3. Class Templates
    4. Multiple Inheritance
    5. Summary
    6. Review Questions
    7. Programming Exercises
  23. FRIENDS, EXCEPTIONS, AND MORE
    1. Friends
    2. Nested Classes
    3. Exceptions
    4. RTTI
    5. Type Cast Operators
    6. Summary
    7. Review Questions
    8. Programming Exercises
  24. THE STRING CLASS AND THE STANDARD TEMPLATE LIBRARY
    1. The string Class
    2. The auto_ptr Class
    3. The Standard Template Library
    4. Generic Programming
    5. Function Objects (aka Functors)
    6. Algorithms
    7. Other Libraries
    8. Summary
    9. Review Questions
    10. Programming Exercises
  25. INPUT, OUTPUT, AND FILES
    1. An Overview of C++ Input and Output
    2. Output with cout
    3. Input with cin
    4. File Input and Output
    5. Incore Formatting
    6. What Now?
    7. Summary
    8. Review Questions
    9. Programming Exercises
  26. NUMBER BASES
    1. Octal Integers
    2. Hexadecimal Numbers
    3. Binary Numbers
    4. Binary and Hex
  27. C++ KEYWORDS
  28. THE ASCII CHARACTER SET
  29. OPERATOR PRECEDENCE
  30. OTHER OPERATORS
    1. Bitwise Operators
    2. Member Dereferencing Operators
  31. THE STRING TEMPLATE CLASS
    1. Thirteen Types and a Constant
    2. Data Information, Constructors, and So On
    3. String Access
    4. Basic Assignment
    5. String Searching
    6. Comparison Methods and Functions
    7. String Modifiers
    8. Output and Input
  32. THE STL METHODS AND FUNCTIONS
    1. Members Common to All Containers
    2. Additional Members for Vectors, Lists, and Deques
    3. Additional Members for Sets and Maps
    4. STL Functions
  33. SELECTED READINGS
    1. Selected Readings
  34. Converting to ANSI/ISO Standard C++
    1. Preprocessor Directives
    2. Use Function Prototypes
    3. Type Casts
    4. Become Familiar with C++ Features
    5. Use the New Header Organization
    6. Use Namespaces
    7. Use the autoptr Template
    8. Use the string Class
    9. Use the STL
  35. ANSWERS TO REVIEW QUESTIONS
    1. Chapter 2
    2. Chapter 3
    3. Chapter 4
    4. Chapter 5
    5. Chapter 6
    6. Chapter 7
    7. Chapter 8
    8. Chapter 9
    9. Chapter 10
    10. Chapter 11
    11. Chapter 12
    12. Chapter 13
    13. Chapter 14
    14. Chapter 15
    15. Chapter 16
  36. Index