Starting Out with C++ from Control Structures to Objects, Global Edition

Höfundur: Tony Gaddis (Útgáfa: 10)
Starting Out with C++ from Control Structures to Objects, Global Edition

Kaup valmöguleikar

RevelĀ® for Starting Out with C++ allows you to learn essential programming concepts and practice coding in one continuous experience. More than a digital textbook, Revel delivers an engaging blend of author content, code exercises, and scored assessment. Using his hallmark accessible, step-by-step presentation, author Tony Gaddis covers control structures, functions, arrays, and pointers before objects and classes.

Every chapter includes clear and easy-to-read code listings, concise and practical real-world examples, focused explanations, and an abundance of exercises. By combining Tony Gaddis' signature, student-friendly approach to teaching programming fundamentals with a dynamic reading experience, Revel empowers you to actively participate in learning. The 10th Edition, Global Edition includes improvements and updates to reflect the latest modern C++ language features, including tuples, lambdas, and new syntactic constructs such as the if statement with initialization.

Nánar um bókina

Útgefandi
Pearson International Content
ISBN
9781292752334
Print ISBN
9781292484471
Format
ePub
Útgáfa
10
Höfundar
Tony Gaddis
Tungumál
English
Útgefið
2025-09-30
Prent takmörkun á líftíma
100
Prent takmörkun
2
Afritunar takmörkun
2

Kaflar

  • Welcome
  • Cover
  • Inside Front Cover
  • Title Page
  • Copyright
  • Acknowledgments
  • For Instructors
  • For Instructors
  • Content Highlights
  • What’s New in the Tenth Edition?
  • Contents at a Glance
  • Detailed Table of Contents
  • Organization of the Text
  • List of Interactive Features
  • List of Interactive Features
  • 1: Introduction to Computers and Programming
  • 1: Topics
  • 1.1: Why Program?
  • 1.1: Why Program?
  • 1.2: Computer Systems: Hardware and Software
  • 1.2: Computer Systems: Hardware and Software
  • The CPU
  • Main Memory
  • Secondary Storage
  • Input Devices
  • Software
  • 1.2: (Noninteractive) Checkpoint Questions from the Book
  • 1.3: Programs and Programming Languages
  • 1.3: Programs and Programming Languages
  • Programming Languages
  • Source Code, Object Code, and Executable Code
  • 1.3: (Noninteractive) Checkpoint Questions from the Book
  • 1.4: What Is a Program Made of?
  • 1.4: What Is a Program Made of?
  • Key Words (Reserved Words)
  • Lines and Statements
  • Variables
  • Variable Definitions
  • 1.5: Input, Processing, and Output
  • 1.5: Input, Processing, and Output
  • 1.5: (Noninteractive) Checkpoint Questions from the Book
  • 1.6: The Programming Process
  • 1.6: The Programming Process
  • A Program Design Example
  • What Is Software Engineering?
  • 1.7: Procedural and Object-Oriented Programming
  • 1.7: Procedural and Object-Oriented Programming
  • 1.7: (Noninteractive) Checkpoint Questions from the Book
  • 1: Review Questions/Algorithm Workbench
  • 1: Review Questions/Algorithm Workbench
  • 2: Introduction to C++
  • 2: Topics
  • 2.1: The Parts of a C++ Program
  • 2.1: The Parts of a C++ Program
  • 2.1: (Noninteractive) Checkpoint Questions from the Book
  • 2.2: The cout Object
  • 2.2: The cout Object
  • Displaying a New Line
  • Raw String Literals
  • 2.3: The #include Directive
  • 2.3: The #include Directive
  • 2.3: (Noninteractive) Checkpoint Questions from the Book
  • 2.4: Variables, Literals, and Assignment Statements
  • 2.4: Variables, Literals, and Assignment Statements
  • Sometimes a Number Isn’t a Number
  • Literals
  • 2.4: (Noninteractive) Checkpoint Questions from the Book
  • 2.5: Identifiers
  • 2.5: Identifiers
  • Legal Identifiers
  • 2.6: Integer Data Types
  • 2.6: Integer Data Types
  • Integer and Long Integer Literals
  • If You Plan to Continue in Computer Science: Binary, Hexadecimal, and Octal Literals
  • 2.6: (Noninteractive) Checkpoint Questions from the Book
  • 2.7: The char Data Type
  • 2.7: The char Data Type
  • The Difference between String Literals and Character Literals
  • 2.8: The C++ string Class
  • 2.8: The C++ string Class
  • 2.8: (Noninteractive) Checkpoint Questions from the Book
  • 2.9: Floating-Point Data Types
  • 2.9: Floating-Point Data Types
  • Floating Point Literals
  • Assigning Floating-Point Values to Integer Variables
  • 2.10: The bool Data Type
  • 2.10: The bool Data Type
  • 2.11: Determining the Size of a Data Type
  • 2.11: Determining the Size of a Data Type
  • 2.11: (Noninteractive) Checkpoint Questions from the Book
  • 2.12: More about Variable Assignments and Initialization
  • 2.12: More about Variable Assignments and Initialization
  • Declaring Variables With the autoKey Word
  • 2.13: Scope
  • 2.13: Scope
  • 2.14: Arithmetic Operators
  • 2.14: Arithmetic Operators
  • Integer Division
  • In the Spotlight: Calculating Percentages and Discounts
  • In the Spotlight: Using the Modulus Operator and Integer Division
  • 2.14: (Noninteractive) Checkpoint Questions from the Book
  • 2.15: Comments
  • 2.15: Comments
  • Single-Line Comments
  • Multi-Line Comments
  • 2.16: Named Constants
  • 2.16: Named Constants
  • 2.16: (Noninteractive) Checkpoint Questions from the Book
  • 2.17: Programming Style
  • 2.17: Programming Style
  • 2: Review Questions/Algorithm Workbench
  • 2: Review Questions/Algorithm Workbench
  • 2: Programming Challenges
  • 2: Programming Challenges
  • 3: Expressions and Interactivity
  • 3: Topics
  • 3.1: The cin Object
  • 3.1: The cin Object
  • Entering Multiple Values
  • 3.1: (Noninteractive) Checkpoint Questions from the Book
  • 3.2: Mathematical Expressions
  • 3.2: Mathematical Expressions
  • Operator Precedence
  • Associativity
  • Grouping with Parentheses
  • Converting Algebraic Expressions to Programming Statements
  • No Exponents Please!
  • In the Spotlight: Calculating an Average
  • 3.2: (Noninteractive) Checkpoint Questions from the Book
  • 3.3: When You Mix Apples and Oranges: Type Conversion
  • 3.3: When You Mix Apples and Oranges: Type Conversion
  • Integer Division
  • 3.4: Overflow and Underflow
  • 3.4: Overflow and Underflow
  • 3.5: Type Casting
  • 3.5: Type Casting
  • 3.5: (Noninteractive) Checkpoint Questions from the Book
  • 3.6: Multiple Assignment and Combined Assignment
  • 3.6: Multiple Assignment and Combined Assignment
  • 3.6: (Noninteractive) Checkpoint Questions from the Book
  • 3.7: Formatting Output
  • 3.7: Formatting Output
  • The setprecision Manipulator
  • The fixed Manipulator
  • The showpoint Manipulator
  • The left and right Manipulators
  • 3.7: (Noninteractive) Checkpoint Questions from the Book
  • 3.8: Working with Characters and string Objects
  • 3.8: Working with Characters and string Objects
  • Inputting a Character
  • Mixing cin >> and cin.get
  • string Member Functions and Operators
  • 3.9: More Mathematical Library Functions
  • 3.9: More Mathematical Library Functions
  • Random Numbers
  • In the Spotlight: Using Random Numbers
  • 3.9: (Noninteractive) Checkpoint Questions from the Book
  • 3.10: Focus on Debugging: Hand Tracing a Program
  • 3.10: Focus on Debugging: Hand Tracing a Program
  • 3.11: Focus on Problem Solving: A Case Study
  • 3.11: Focus on Problem Solving: A Case Study
  • Program Design
  • Calculations
  • 3: Review Questions/Algorithm Workbench
  • 3: Review Questions/Algorithm Workbench
  • 3: Programming Challenges
  • 3: Programming Challenges
  • 4: Making Decisions
  • 4: Topics
  • 4.1: Relational Operators
  • 4.1: Relational Operators
  • The Value of a Relationship
  • What is Truth?
  • 4.1: (Noninteractive) Checkpoint Questions from the Book
  • 4.2: The if Statement
  • 4.2: The if Statement
  • Be Careful with Semicolons
  • Programming Style and the if Statement
  • Comparing Floating-Point Numbers
  • And Now Back to Truth
  • Don’t Confuse == With =
  • 4.2: (Noninteractive) Checkpoint Questions from the Book
  • 4.3: Expanding the if Statement
  • 4.3: Expanding the if Statement
  • Don’t Forget the Braces!
  • 4.3: (Noninteractive) Checkpoint Questions from the Book
  • 4.4: The if/else Statement
  • 4.4: The if/else Statement
  • 4.4: (Noninteractive) Checkpoint Questions from the Book
  • 4.5: Nested if Statements
  • 4.5: Nested if Statements
  • Programming Style and Nested Decision Structures
  • In the Spotlight: Multiple Nested Decision Structures
  • 4.5: (Noninteractive) Checkpoint Questions from the Book
  • 4.6: The if/else if Statement
  • 4.6: The if/else if Statement
  • Using the Trailing else To Catch Errors
  • The if/else if Statement Compared to a Nested Decision Structure
  • 4.6: (Noninteractive) Checkpoint Questions from the Book
  • 4.7: The if Statement with Initialization
  • 4.7: The if Statement with Initialization
  • 4.8: Flags
  • 4.8: Flags
  • Integer Flags
  • 4.9: Logical Operators
  • 4.9: Logical Operators
  • The && Operator
  • The || Operator
  • The ! Operator
  • Precedence and Associativity of Logical Operators
  • 4.10: Checking Numeric Ranges with Logical Operators
  • 4.10: Checking Numeric Ranges with Logical Operators
  • 4.10: (Noninteractive) Checkpoint Questions from the Book
  • 4.11: Menus
  • 4.11: Menus
  • 4.12: Focus on Software Engineering: Validating User Input
  • 4.12: Focus on Software Engineering: Validating User Input
  • 4.13: Comparing Characters and Strings
  • 4.13: Comparing Characters and Strings
  • Comparing string Objects
  • 4.13: (Noninteractive) Checkpoint Questions from the Book
  • 4.14: The Conditional Operator
  • 4.14: The Conditional Operator
  • Using the Value of a Conditional Expression
  • 4.14: (Noninteractive) Checkpoint Questions from the Book
  • 4.15: The switch Statement
  • 4.15: The switch Statement
  • Using switch in Menu Systems
  • 4.15: (Noninteractive) Checkpoint Questions from the Book
  • 4.16: The switch Statement with Initialization
  • 4.16: The switch Statement with Initialization
  • 4.17: More about Blocks and Variable Scope
  • 4.17: More about Blocks and Variable Scope
  • Variables with the Same Name
  • 4: Review Questions/Algorithm Workbench
  • 4: Review Questions/Algorithm Workbench
  • 4: Programming Challenges
  • 4: Programming Challenges
  • 5: Loops and Files
  • 5: Topics
  • 5.1: The Increment and Decrement Operators
  • 5.1: The Increment and Decrement Operators
  • The Difference Between Postfix and Prefix Modes
  • Using ++ and −− in Mathematical Expressions
  • Using ++ and −− in Relational Expressions
  • 5.1: (Noninteractive) Checkpoint Questions from the Book
  • 5.2: Introduction to Loops: The while Loop
  • 5.2: Introduction to Loops: The while Loop
  • The while Loop Is a Pretest Loop
  • Infinite Loops
  • Don’t Forget the Braces with a Block of Statements
  • Programming Style and the while Loop
  • In the Spotlight: Designing a Program with a while Loop
  • 5.3: Using the while Loop for Input Validation
  • 5.3: Using the while Loop for Input Validation
  • 5.3: (Noninteractive) Checkpoint Questions from the Book
  • 5.4: Counters
  • 5.4: Counters
  • 5.5: The do-while Loop
  • 5.5: The do-while Loop
  • Using do-while with Menus
  • 5.5: (Noninteractive) Checkpoint Questions from the Book
  • 5.6: The for Loop
  • 5.6: The for Loop
  • Using the for Loop Instead of while or do-while
  • The for Loop Is a Pretest Loop
  • Avoid Modifying the Counter Variable in the Body of the for Loop
  • Other Forms of the Update Expression
  • Defining a Variable in the for Loop’s Initialization Expression
  • Creating a User Controlled for Loop
  • Using Multiple Statements in the Initialization and Update Expressions
  • Omitting the for Loop’s Expressions
  • In the Spotlight: Designing a Count-Controlled Loop with the for Statement
  • 5.6: (Noninteractive) Checkpoint Questions from the Book
  • 5.7: Keeping a Running Total
  • 5.7: Keeping a Running Total
  • 5.8: Sentinels
  • 5.8: Sentinels
  • 5.8: (Noninteractive) Checkpoint Questions from the Book
  • 5.9: Focus on Software Engineering: Deciding Which Loop to Use
  • 5.9: Focus on Software Engineering: Deciding Which Loop to Use
  • 5.10: Nested Loops
  • 5.10: Nested Loops
  • 5.11: Using Files for Data Storage
  • 5.11: Using Files for Data Storage
  • Types of Files
  • File Access Methods
  • Filenames and File Stream Objects
  • Setting Up a Program for File Input/Output
  • Creating a File Object and Opening a File
  • Closing a File
  • Writing Data to a File
  • Reading Data from a File
  • The Read Position
  • Reading Numeric Data from a Text File
  • Using Loops to Process Files
  • Detecting the End of the File
  • Testing for File Open Errors
  • Letting the User Specify a Filename
  • Using the c_str Member Function in Older Versions of C++
  • 5.11: (Noninteractive) Checkpoint Questions from the Book
  • 5.12: Optional Topics: Breaking and Continuing a Loop
  • 5.12: Optional Topics: Breaking and Continuing a Loop
  • Using break in a Nested Loop
  • The continue Statement
  • 5: Review Questions/Algorithm Workbench
  • 5: Review Questions/Algorithm Workbench
  • 5: Programming Challenges
  • 5: Programming Challenges
  • 6: Functions
  • 6: Topics
  • 6.1: Focus on Software Engineering: Modular Programming
  • 6.1: Focus on Software Engineering: Modular Programming
  • 6.2: Defining and Calling Functions
  • 6.2: Defining and Calling Functions
  • Calling a Function
  • Using Multiple Functions in a Program
  • Layered Function Calls
  • 6.2: (Noninteractive) Checkpoint Questions from the Book
  • 6.3: Function Prototypes
  • 6.3: Function Prototypes
  • 6.4: Sending Data into a Function
  • 6.4: Sending Data into a Function
  • Passing Multiple Arguments
  • 6.5: Passing Data by Value
  • 6.5: Passing Data by Value
  • 6.6: Focus on Software Engineering: Using Functions in a Menu-Driven Program
  • 6.6: Focus on Software Engineering: Using Functions in a Menu-Driven Program
  • 6.6: (Noninteractive) Checkpoint Questions from the Book
  • 6.7: The return Statement
  • 6.7: The return Statement
  • 6.8: Returning a Value from a Function
  • 6.8: Returning a Value from a Function
  • Defining a Value-Returning Function
  • Calling a Value-Returning Function
  • In the Spotlight: Using Functions
  • 6.9: Returning a Boolean Value
  • 6.9: Returning a Boolean Value
  • 6.9: (Noninteractive) Checkpoint Questions from the Book
  • 6.10: Local and Global Variables
  • 6.10: Local and Global Variables
  • Global Variables
  • Global Constants
  • Local and Global Variables with the Same Name
  • 6.11: Static Local Variables
  • 6.11: Static Local Variables
  • 6.11: (Noninteractive) Checkpoint Questions from the Book
  • 6.12: Default Arguments
  • 6.12: Default Arguments
  • 6.13: Using Reference Variables as Parameters
  • 6.13: Using Reference Variables as Parameters
  • 6.13: (Noninteractive) Checkpoint Questions from the Book
  • 6.14: Overloading Functions
  • 6.14: Overloading Functions
  • 6.15: The exit() Function
  • 6.15: The exit() Function
  • 6.15: (Noninteractive) Checkpoint Questions from the Book
  • 6.16: Stubs and Drivers
  • 6.16: Stubs and Drivers
  • 6: Review Questions/Algorithm Workbench
  • 6: Review Questions/Algorithm Workbench
  • 6: Programming Challenges
  • 6: Programming Challenges
  • 7: Arrays and Vectors
  • 7: Topics
  • 7.1: Arrays Hold Multiple Values
  • 7.1: Arrays Hold Multiple Values
  • 7.2: Accessing Array Elements
  • 7.2: Accessing Array Elements
  • Inputting and Outputting Array Contents
  • Stepping Through an Array
  • Array Initialization
  • Partial Array Initialization
  • Working with Arrays and Files
  • 7.3: No Bounds Checking in C++
  • 7.3: No Bounds Checking in C++
  • 7.3: (Noninteractive) Checkpoint Questions from the Book
  • 7.4: The Range-Based for Loop
  • 7.4: The Range-Based for Loop
  • Modifying an Array with a Range-Based for Loop
  • 7.5: Processing Array Contents
  • 7.5: Processing Array Contents
  • Thou Shall Not Assign
  • Printing the Contents of an Array
  • Summing the Values in a Numeric Array
  • Getting the Average of the Values in a Numeric Array
  • Finding the Highest and Lowest Values in a Numeric Array
  • Partially Filled Arrays
  • Comparing Arrays
  • Using Structured Binding Declarations with Arrays
  • 7.6: Focus on Software Engineering: Using Parallel Arrays
  • 7.6: Focus on Software Engineering: Using Parallel Arrays
  • 7.6: (Noninteractive) Checkpoint Questions from the Book
  • 7.7: Arrays as Function Arguments
  • 7.7: Arrays as Function Arguments
  • Using const Array Parameters
  • In the Spotlight: Processing an Array
  • 7.7: (Noninteractive) Checkpoint Questions from the Book
  • 7.8: Two-Dimensional Arrays
  • 7.8: Two-Dimensional Arrays
  • Passing Two-Dimensional Arrays to Functions
  • Summing All the Elements of a Two-Dimensional Array
  • Summing the Rows of a Two-Dimensional Array
  • Summing the Columns of a Two-Dimensional Array
  • 7.9: Arrays with Three or More Dimensions
  • 7.9: Arrays with Three or More Dimensions
  • 7.9: (Noninteractive) Checkpoint Questions from the Book
  • 7.10: Focus on Problem Solving and Program Design: A Case Study
  • 7.10: Focus on Problem Solving and Program Design: A Case Study
  • 7.11: Introduction to the STL vector
  • 7.11: Introduction to the STL vector
  • Defining a vector
  • Storing and Retrieving Values in a vector
  • Using the Range-Based for Loop with a vector in C++ 11
  • Using the push_back Member Function
  • Determining the Size of a vector
  • Removing Elements from a vector
  • Clearing a vector
  • Detecting an Empty vector
  • Summary of vector Member Functions
  • 7.11: (Noninteractive) Checkpoint Questions from the Book
  • 7: Review Questions/Algorithm Workbench
  • 7: Review Questions/Algorithm Workbench
  • 7: Programming Challenges
  • 7: Programming Challenges
  • 8: Searching and Sorting Arrays
  • 8: Topics
  • 8.1: Focus on Software Engineering: Introduction to Search Algorithms
  • 8.1: Focus on Software Engineering: Introduction to Search Algorithms
  • Inefficiency of the Linear Search
  • The Binary Search
  • The Efficiency of the Binary Search
  • 8.2: Focus on Problem Solving and Program Design: A Case Study
  • 8.2: Focus on Problem Solving and Program Design: A Case Study
  • Variables
  • Function main
  • The getProdNum Function
  • The binarySearch Function
  • The Entire Program
  • 8.2: (Noninteractive) Checkpoint Questions from the Book
  • 8.3: Focus on Software Engineering: Introduction to Sorting Algorithms
  • 8.3: Focus on Software Engineering: Introduction to Sorting Algorithms
  • The Selection Sort Algorithm
  • 8.4: Focus on Problem Solving and Program Design: A Case Study
  • 8.4: Focus on Problem Solving and Program Design: A Case Study
  • Variables
  • Modules
  • Function main
  • The calcSales Function
  • The dualSort Function
  • The showOrder Function
  • The showTotals Function
  • The Entire Program
  • 8.5: Sorting and Searching vectors (Continued from Section 7.11)
  • 8.5: Sorting and Searching vectors (Continued from Section 7.11)
  • 8: Review Questions/Algorithm Workbench
  • 8: Review Questions/Algorithm Workbench
  • 8: Programming Challenges
  • 8: Programming Challenges
  • 9: Pointers
  • 9: Topics
  • 9.1: Getting the Address of a Variable
  • 9.1: Getting the Address of a Variable
  • 9.1: (Noninteractive) Checkpoint Questions from the Book
  • 9.2: Pointer Variables
  • 9.2: Pointer Variables
  • Creating and Using Pointer Variables
  • 9.2: (Noninteractive) Checkpoint Questions from the Book
  • 9.3: The Relationship Between Arrays and Pointers
  • 9.3: The Relationship Between Arrays and Pointers
  • 9.3: (Noninteractive) Checkpoint Questions from the Book
  • 9.4: Pointer Arithmetic
  • 9.4: Pointer Arithmetic
  • 9.4: (Noninteractive) Checkpoint Questions from the Book
  • 9.5: Initializing Pointers
  • 9.5: Initializing Pointers
  • 9.5: (Noninteractive) Checkpoint Questions from the Book
  • 9.6: Comparing Pointers
  • 9.6: Comparing Pointers
  • 9.6: (Noninteractive) Checkpoint Questions from the Book
  • 9.7: Pointers as Function Parameters
  • 9.7: Pointers as Function Parameters
  • Pointers to Constants
  • Passing a Nonconstant Argument into a Pointer to a Constant
  • Constant Pointers
  • 9.7: (Noninteractive) Checkpoint Questions from the Book
  • 9.8: Dynamic Memory Allocation
  • 9.8: Dynamic Memory Allocation
  • 9.8: (Noninteractive) Checkpoint Questions from the Book
  • 9.9: Returning Pointers from Functions
  • 9.9: Returning Pointers from Functions
  • In the Spotlight: Returning a Pointer From a Function
  • 9.9: (Noninteractive) Checkpoint Questions from the Book
  • 9.10: Using Smart Pointers to Avoid Memory Leaks
  • 9.10: Using Smart Pointers to Avoid Memory Leaks
  • 9.10: (Noninteractive) Checkpoint Questions from the Book
  • 9.11: Focus on Problem Solving and Program Design: A Case Study
  • 9.11: Focus on Problem Solving and Program Design: A Case Study
  • The Entire Program
  • 9: Review Questions/Algorithm Workbench
  • 9: Review Questions/Algorithm Workbench
  • 9: Programming Challenges
  • 9: Programming Challenges
  • 10: Characters, C-Strings, and More about the string Class
  • 10: Topics
  • 10.1: Character Testing
  • 10.1: Character Testing
  • 10.2: Character Case Conversion
  • 10.2: Character Case Conversion
  • 10.2: (Noninteractive) Checkpoint Questions from the Book
  • 10.3: C-Strings
  • 10.3: C-Strings
  • More About String Literals
  • C-Strings Stored in Arrays
  • 10.4: Library Functions for Working with C-Strings
  • 10.4: Library Functions for Working with C-Strings
  • The strcat Function
  • The strcpy Function
  • The strncat and strncpy Functions
  • The strstr Function
  • The strcmp Function
  • Sorting Strings
  • 10.4: (Noninteractive) Checkpoint Questions from the Book
  • 10.5: String/Numeric Conversion Functions
  • 10.5: String/Numeric Conversion Functions
  • The to_string Function
  • 10.5: (Noninteractive) Checkpoint Questions from the Book
  • 10.6: Focus on Software Engineering: Writing Your Own C-String-Handling Functions
  • 10.6: Focus on Software Engineering: Writing Your Own C-String-Handling Functions
  • Using Pointers to Pass C-String Arguments
  • 10.6: (Noninteractive) Checkpoint Questions from the Book
  • 10.7: More about the C++ string Class
  • 10.7: More about the C++ string Class
  • Reading a Line of Input into a string Object
  • Comparing and Sorting string Objects
  • Other Ways to Define string Objects
  • Using string Class Member Functions
  • In the Spotlight: String Tokenizing
  • 10.8: Focus on Problem Solving and Program Design: A Case Study
  • 10.8: Focus on Problem Solving and Program Design: A Case Study
  • 10: Review Questions/Algorithm Workbench
  • 10: Review Questions/Algorithm Workbench
  • 10: Programming Challenges
  • 10: Programming Challenges
  • 11: Structured Data
  • 11: Topics
  • 11.1: Abstract Data Types
  • 11.1: Abstract Data Types
  • 11.2: Structures
  • 11.2: Structures
  • 11.3: Accessing Structure Members
  • 11.3: Accessing Structure Members
  • 11.4: Initializing a Structure
  • 11.4: Initializing a Structure
  • 11.4: (Noninteractive) Checkpoint Questions from the Book
  • 11.5: Arrays of Structures
  • 11.5: Arrays of Structures
  • 11.6: Focus on Software Engineering: Nested Structures
  • 11.6: Focus on Software Engineering: Nested Structures
  • 11.6: (Noninteractive) Checkpoint Questions from the Book
  • 11.7: Structures as Function Arguments
  • 11.7: Structures as Function Arguments
  • Constant Reference Parameters
  • 11.8: Returning a Structure from a Function
  • 11.8: Returning a Structure from a Function
  • 11.9: Using Structured Binding Declarations with Structures
  • 11.9: Using Structured Binding Declarations with Structures
  • 11.10: Pointers to Structures
  • 11.10: Pointers to Structures
  • Dynamically Allocating a Structure
  • 11.11: Focus on Software Engineering: When to Use . , When to Use -> , and When to Use *
  • 11.11: Focus on Software Engineering: When to Use . , When to Use -> , and When to Use *
  • 11.11: (Noninteractive) Checkpoint Questions from the Book
  • 11.12: Enumerated Data Types
  • 11.12: Enumerated Data Types
  • Assigning an Integer to an enum Variable
  • Assigning an Enumerator to an int Variable
  • Comparing Enumerator Values
  • Anonymous Enumerated Types
  • Using Math Operators to Change the Value of an enum Variable
  • Using an enum Variable to Step Through an Array’s Elements
  • Using Enumerators to Output Values
  • Specifying Integer Values for Enumerators
  • Enumerators Must Be Unique Within the Same Scope
  • Declaring the Type and Defining the Variables in One Statement
  • Strongly Typed enums
  • 11.12: (Noninteractive) Checkpoint Questions from the Book
  • 11: Review Questions/Algorithm Workbench
  • 11: Review Questions/Algorithm Workbench
  • 11: Programming Challenges
  • 11: Programming Challenges
  • 12: Advanced File Operations
  • 12: Topics
  • 12.1: File Operations
  • 12.1: File Operations
  • Using the fstream Data Type
  • File Open Modes with ifstream and ofstream Objects
  • Checking for a File’s Existence Before Opening It
  • Opening a File with the File Stream Object Definition Statement
  • 12.1: (Noninteractive) Checkpoint Questions from the Book
  • 12.2: File Output Formatting
  • 12.2: File Output Formatting
  • 12.3: Passing File Stream Objects to Functions
  • 12.3: Passing File Stream Objects to Functions
  • 12.4: More Detailed Error Testing
  • 12.4: More Detailed Error Testing
  • 12.5: Member Functions for Reading and Writing Files
  • 12.5: Member Functions for Reading and Writing Files
  • The getline Function
  • The get Member Function
  • The put Member Function
  • 12.5: (Noninteractive) Checkpoint Questions from the Book
  • 12.6: Focus on Software Engineering: Working with Multiple Files
  • 12.6: Focus on Software Engineering: Working with Multiple Files
  • 12.7: Binary Files
  • 12.7: Binary Files
  • The write and read Member Functions
  • Writing Data Other Than char to Binary Files
  • 12.8: Creating Records with Structures
  • 12.8: Creating Records with Structures
  • 12.9: Random-Access Files
  • 12.9: Random-Access Files
  • The seekp and seekg Member Functions
  • The tellp and tellg Member Functions
  • Rewinding a Sequential-Access File with seekg
  • 12.10: Opening a File for Both Input and Output
  • 12.10: Opening a File for Both Input and Output
  • 12.10: (Noninteractive) Checkpoint Questions from the Book
  • 12.11: Working with the File System
  • 12.11: Working with the File System
  • Working with path Objects
  • Determining Whether a File or Directory Exists
  • Copying a File
  • Deleting a File or Empty Directory
  • Renaming a File or Directory
  • Getting and Setting the Path of the Current Working Directory
  • Creating a Directory
  • Deleting a Nonempty Directory
  • Getting the Contents of a Directory
  • More About directory_entry Objects
  • More About path Objects
  • 12.11: (Noninteractive) Checkpoint Questions from the Book
  • 12: Review Questions/Algorithm Workbench
  • 12: Review Questions/Algorithm Workbench
  • 12: Programming Challenges
  • 12: Programming Challenges
  • 13: Introduction to Classes
  • 13: Topics
  • 13.1: Procedural and Object-Oriented Programming
  • 13.1: Procedural and Object-Oriented Programming
  • Classes and Objects
  • Using a Class You Already Know
  • 13.2: Introduction to Classes
  • 13.2: Introduction to Classes
  • Access Specifiers
  • Public Member Functions
  • Placement of public and private Members
  • Defining Member Functions
  • Accessors and Mutators
  • The Importance of Data Hiding
  • 13.3: Defining an Instance of a Class
  • 13.3: Defining an Instance of a Class
  • A Class Demonstration Program
  • Avoiding Stale Data
  • Pointers to Objects
  • Using Smart Pointers to Allocate Objects
  • 13.3: (Noninteractive) Checkpoint Questions from the Book
  • 13.4: Why Have Private Members?
  • 13.4: Why Have Private Members?
  • 13.5: Focus on Software Engineering: Separating Class Specification from Implementation
  • 13.5: Focus on Software Engineering: Separating Class Specification from Implementation
  • 13.6: Inline Member Functions
  • 13.6: Inline Member Functions
  • 13.6: (Noninteractive) Checkpoint Questions from the Book
  • 13.7: Constructors
  • 13.7: Constructors
  • The Default Constructor
  • 13.8: Passing Arguments to Constructors
  • 13.8: Passing Arguments to Constructors
  • Using Default Arguments with Constructors
  • More about the Default Constructor
  • 13.9: Destructors
  • 13.9: Destructors
  • 13.9: (Noninteractive) Checkpoint Questions from the Book
  • 13.10: Overloading Constructors
  • 13.10: Overloading Constructors
  • 13.11: Private Member Functions
  • 13.11: Private Member Functions
  • 13.12: Arrays of Objects
  • 13.12: Arrays of Objects
  • Accessing Members of Objects in an Array
  • 13.12: (Noninteractive) Checkpoint Questions from the Book
  • 13.13: Focus on Problem Solving and Program Design: An OOP Case Study
  • 13.13: Focus on Problem Solving and Program Design: An OOP Case Study
  • The Class Declaration
  • The withdraw Member Function
  • The Class’s Interface
  • Implementing the Class
  • 13.14: Focus on Object-Oriented Programming: Simulating Dice with Objects
  • 13.14: Focus on Object-Oriented Programming: Simulating Dice with Objects
  • 13.15: Focus on Object-Oriented Design: The Unified Modeling Language (UML)
  • 13.15: Focus on Object-Oriented Design: The Unified Modeling Language (UML)
  • Showing Access Specification in UML Diagrams
  • Data Type and Parameter Notation in UML Diagrams
  • Showing Constructors and Destructors in a UML Diagram
  • 13.16: Focus on Object-Oriented Design: Finding the Classes and Their Responsibilities
  • 13.16: Focus on Object-Oriented Design: Finding the Classes and Their Responsibilities
  • Write a Description of the Problem Domain
  • Identify All of the Nouns
  • Refine the List of Nouns
  • Identifying a Class’s Responsibilities
  • The Customer Class
  • The Car Class
  • The ServiceQuote Class
  • This Is Only the Beginning
  • 13.16: (Noninteractive) Checkpoint Questions from the Book
  • 13: Review Questions/Algorithm Workbench
  • 13: Review Questions/Algorithm Workbench
  • 13: Programming Challenges
  • 13: Programming Challenges
  • 14: More about Classes
  • 14: Topics
  • 14.1: Instance and Static Members
  • 14.1: Instance and Static Members
  • Static Members
  • Static Member Variables
  • 14.2: Friends of Classes
  • 14.2: Friends of Classes
  • 14.2: (Noninteractive) Checkpoint Questions from the Book
  • 14.3: Memberwise Assignment
  • 14.3: Memberwise Assignment
  • 14.4: Copy Constructors
  • 14.4: Copy Constructors
  • Using const Parameters in Copy Constructors
  • Copy Constructors and Function Parameters
  • 14.4: (Noninteractive) Checkpoint Questions from the Book
  • 14.5: Operator Overloading
  • 14.5: Operator Overloading
  • The this Pointer
  • Overloading the = Operator
  • The = Operator’s Return Value
  • Some General Issues of Operator Overloading
  • Overloading Math Operators
  • Overloading the Prefix ++ Operator
  • Overloading the Postfix ++ Operator
  • Overloading Relational Operators
  • Overloading the << and >> Operators
  • Overloading the [ ] Operator
  • 14.5: (Noninteractive) Checkpoint Questions from the Book - Part I
  • 14.5: (Noninteractive) Checkpoint Questions from the Book - Part II
  • 14.6: Object Conversion
  • 14.6: Object Conversion
  • 14.6: (Noninteractive) Checkpoint Questions from the Book
  • 14.7: Aggregation
  • 14.7: Aggregation
  • Aggregation in UML Diagrams
  • 14.8: Focus on Object-Oriented Design: Class Collaborations
  • 14.8: Focus on Object-Oriented Design: Class Collaborations
  • Determining Class Collaborations with CRC Cards
  • 14.8: (Noninteractive) Checkpoint Questions from the Book
  • 14.9: Focus on Object-Oriented Programming: Simulating the Game of Cho-Han
  • 14.9: Focus on Object-Oriented Programming: Simulating the Game of Cho-Han
  • 14.10: Rvalue References and Move Semantics
  • 14.10: Rvalue References and Move Semantics
  • Rvalue References
  • Move Semantics
  • When to Implement Move Semantics in a Class
  • 14: Review Questions/Algorithm Workbench
  • 14: Review Questions/Algorithm Workbench
  • 14: Programming Challenges
  • 14: Programming Challenges
  • 15: Inheritance, Polymorphism, and Virtual Functions
  • 15: Topics
  • 15.1: What Is Inheritance?
  • 15.1: What Is Inheritance?
  • Base Class Example: GradedActivity
  • Derived Class Example: FinalExam
  • 15.1: (Noninteractive) Checkpoint Questions from the Book
  • 15.2: Protected Members and Class Access
  • 15.2: Protected Members and Class Access
  • More about Base Class Access Specification
  • 15.2: (Noninteractive) Checkpoint Questions from the Book
  • 15.3: Constructors and Destructors in Base and Derived Classes
  • 15.3: Constructors and Destructors in Base and Derived Classes
  • Passing Arguments to Base Class Constructors
  • In the Spotlight: The Automobile, Car, Truck, and SUV classes
  • Constructor Inheritance
  • 15.3: (Noninteractive) Checkpoint Questions from the Book
  • 15.4: Redefining Base Class Functions
  • 15.4: Redefining Base Class Functions
  • 15.5: Class Hierarchies
  • 15.5: Class Hierarchies
  • 15.6: Polymorphism and Virtual Member Functions
  • 15.6: Polymorphism and Virtual Member Functions
  • Polymorphism Requires References or Pointers
  • Base Class Pointers
  • Base Class Pointers and References Know Only About Base Class Members
  • The “Is-a” Relationship Does Not Work in Reverse
  • Redefining versus Overriding
  • Virtual Destructors
  • The override and final Key Words
  • Preventing a Member Function from Being Overridden
  • 15.7: Abstract Base Classes and Pure Virtual Functions
  • 15.7: Abstract Base Classes and Pure Virtual Functions
  • 15.7: (Noninteractive) Checkpoint Questions from the Book
  • 15.8: Multiple Inheritance
  • 15.8: Multiple Inheritance
  • 15.8: (Noninteractive) Checkpoint Questions from the Book
  • 15: Review Questions/Algorithm Workbench
  • 15: Review Questions/Algorithm Workbench
  • 15: Programming Challenges
  • 15: Programming Challenges
  • 16: Exceptions and Templates
  • 16: Topics
  • 16.1: Exceptions
  • 16.1: Exceptions
  • Object-Oriented Exception Handling with Classes
  • Multiple Exceptions
  • Extracting Data from the Exception Class
  • Unwinding the Stack
  • Rethrowing an Exception
  • Handling the bad_alloc Exception
  • Using the noexcept Key Word
  • 16.1: (Noninteractive) Checkpoint Questions from the Book
  • 16.2: Function Templates
  • 16.2: Function Templates
  • Using Operators in Function Templates
  • Function Templates with Multiple Types
  • Overloading with Function Templates
  • 16.3: Focus on Software Engineering: Where to Start When Defining Templates
  • 16.3: Focus on Software Engineering: Where to Start When Defining Templates
  • 16.3: (Noninteractive) Checkpoint Questions from the Book
  • 16.4: Class Templates
  • 16.4: Class Templates
  • Defining Objects of the Class Template
  • Class Templates and Inheritance
  • Specialized Templates
  • 16.4: (Noninteractive) Checkpoint Questions from the Book
  • 16: Review Questions/Algorithm Workbench
  • 16: Review Questions/Algorithm Workbench
  • 16: Programming Challenges
  • 16: Programming Challenges
  • 17: The Standard Template Library
  • 17: Topics
  • 17.1: Introduction to the Standard Template Library
  • 17.1: Introduction to the Standard Template Library
  • 17.2: STL Container and Iterator Fundamentals
  • 17.2: STL Container and Iterator Fundamentals
  • Introduction to the array Class
  • Iterators
  • Getting an Iterator from a Container Object
  • Using auto to Define an Iterator
  • Mutable Iterators and const_iterators
  • Reverse Iterators
  • 17.2: (Noninteractive) Checkpoint Questions from the Book
  • 17.3: The vector Class
  • 17.3: The vector Class
  • Review of Basic vector Operations
  • Using an Iterator with a vector
  • Inserting New Elements into a vector
  • Storing Objects of Your Own Classes as Values in a vector
  • Inserting Elements with the emplace() and emplace_back() Member Functions
  • The capacity(), max_size(), shrink_to_fit(), and reserve() Member Functions
  • 17.3: (Noninteractive) Checkpoint Questions from the Book
  • 17.4: The map, multimap, and unordered_map Classes
  • 17.4: The map, multimap, and unordered_map Classes
  • The map Class
  • Initializing a Map
  • Adding Elements to an Existing Map
  • Adding Elements with the insert() Member Function
  • Adding Elements with the emplace() Member Function
  • Retrieving Values from a Map
  • Deleting Elements
  • Iterating Over a Map with the Range-Based for Loop
  • Using an Iterator with a Map
  • Storing vectors as Values in a map
  • Storing Objects of Your Own Classes as Values in a map
  • Using an Object of Your Own Class as a Key
  • The unordered_map Class
  • The multimap Class
  • Adding Elements to a multimap
  • Getting the Number of Elements with a Specified Key
  • Retrieving the Elements with a Specified Key
  • Deleting Elements from a multimap
  • The unordered_multimap Class
  • 17.4: (Noninteractive) Checkpoint Questions from the Book
  • 17.5: The set, multiset, and unordered_set Classes
  • 17.5: The set, multiset, and unordered_set Classes
  • Adding Elements to an Existing set
  • Iterating Over a set with the Range-Based for Loop
  • Using an Iterator with a set
  • Determining Whether a Value Exists in a set
  • Storing Objects of Your Own Classes in a set
  • The multiset Class
  • The unordered_set and unordered_multiset Classes
  • 17.5: (Noninteractive) Checkpoint Questions from the Book
  • 17.6: The tuple Class
  • 17.6: The tuple Class
  • Retrieving Items By Index From a Tuple
  • Modifying the Contents of an Existing Tuple
  • Assigning One Tuple to Another
  • Swapping Tuples
  • Unpacking a Tuple
  • 17.6: (Noninteractive) Checkpoint Questions from the Book
  • 17.7: Algorithms
  • 17.7: Algorithms
  • Sorting and Searching Algorithms
  • Detecting Permutations
  • Plugging Your Own Functions into an Algorithm
  • Using the STL to Perform Set Operations
  • Finding the Union of Sets with the set_union Function
  • Finding the Intersection of Sets with the set_intersection Function
  • Finding the Difference of Sets with the set_difference Function
  • Finding the Symmetric Difference of Sets with the set_symmetric_difference Function
  • Finding Subsets
  • In the Spotlight: Set Operations
  • 17.7: (Noninteractive) Checkpoint Questions from the Book
  • 17.8: Introduction to Function Objects and Lambda Expressions
  • 17.8: Introduction to Function Objects and Lambda Expressions
  • Constructing an Anonymous Function Object
  • Predicate Terminology
  • Lambda Expressions
  • Functional Classes in the STL
  • 17.8: (Noninteractive) Checkpoint Questions from the Book
  • 17: Review Questions/Algorithm Workbench
  • 17: Review Questions/Algorithm Workbench
  • 17: Programming Challenges
  • 17: Programming Challenges
  • 18: Linked Lists
  • 18: Topics
  • 18.1: Introduction to the Linked List ADT
  • 18.1: Introduction to the Linked List ADT
  • 18.1: (Noninteractive) Checkpoint Questions from the Book
  • 18.2: Linked List Operations
  • 18.2: Linked List Operations
  • Appending a Node to the List
  • Traversing a Linked List
  • Inserting a Node
  • Deleting a Node
  • Destroying the List
  • 18.2: (Noninteractive) Checkpoint Questions from the Book - Part I
  • 18.2: (Noninteractive) Checkpoint Questions from the Book - Part II
  • 18.3: A Linked List Template
  • 18.3: A Linked List Template
  • Using a Class Node Type
  • 18.4: Variations of the Linked List
  • 18.4: Variations of the Linked List
  • 18.5: The STL list and forward_list Containers
  • 18.5: The STL list and forward_list Containers
  • The list Container
  • The forward_list Container
  • 18: Review Questions/Algorithm Workbench
  • 18: Review Questions/Algorithm Workbench
  • 18: Programming Challenges
  • 18: Programming Challenges
  • 19: Stacks and Queues
  • 19: Topics
  • 19.1: Introduction to the Stack ADT
  • 19.1: Introduction to the Stack ADT
  • A Static Stack Class
  • Implementing Other Stack Operations
  • A Static Stack Template
  • 19.2: Dynamic Stacks
  • 19.2: Dynamic Stacks
  • A Dynamic Stack Template
  • 19.3: The STL stack Container
  • 19.3: The STL stack Container
  • 19.3: (Noninteractive) Checkpoint Questions from the Book
  • 19.4: Introduction to the Queue ADT
  • 19.4: Introduction to the Queue ADT
  • Queue Operations
  • A Static Queue Class
  • A Static Queue Template
  • 19.5: Dynamic Queues
  • 19.5: Dynamic Queues
  • A Dynamic Queue Template
  • 19.6: The STL deque and queue Containers
  • 19.6: The STL deque and queue Containers
  • The queue Container Adapter
  • 19: Review Questions/Algorithm Workbench
  • 19: Review Questions/Algorithm Workbench
  • 19: Programming Challenges
  • 19: Programming Challenges
  • 20: Recursion
  • 20: Topics
  • 20.1: Introduction to Recursion
  • 20.1: Introduction to Recursion
  • 20.2: Solving Problems with Recursion
  • 20.2: Solving Problems with Recursion
  • Example: Using Recursion to Calculate the Factorial of a Number
  • Example: Using Recursion to Count Characters
  • Direct and Indirect Recursion
  • 20.2: (Noninteractive) Checkpoint Questions from the Book
  • 20.3: Focus on Problem Solving and Program Design: The Recursive gcd Function
  • 20.3: Focus on Problem Solving and Program Design: The Recursive gcd Function
  • 20.4: Focus on Problem Solving and Program Design: Solving Recursively Defined Problems
  • 20.4: Focus on Problem Solving and Program Design: Solving Recursively Defined Problems
  • 20.5: Focus on Problem Solving and Program Design: Recursive Linked List Operations
  • 20.5: Focus on Problem Solving and Program Design: Recursive Linked List Operations
  • Counting the Nodes in the List
  • Displaying List Nodes in Reverse Order
  • 20.6: Focus on Problem Solving and Program Design: A Recursive Binary Search Function
  • 20.6: Focus on Problem Solving and Program Design: A Recursive Binary Search Function
  • 20.7: The Towers of Hanoi
  • 20.7: The Towers of Hanoi
  • 20.8: Focus on Problem Solving and Program Design: The QuickSort Algorithm
  • 20.8: Focus on Problem Solving and Program Design: The QuickSort Algorithm
  • 20.9: Exhaustive Algorithms
  • 20.9: Exhaustive Algorithms
  • 20.10: Recursion and Variadic Function Templates
  • 20.10: Recursion and Variadic Function Templates
  • 20.11: Focus on Software Engineering: Recursion versus Iteration
  • 20.11: Focus on Software Engineering: Recursion versus Iteration
  • 20: Review Questions/Algorithm Workbench
  • 20: Review Questions/Algorithm Workbench
  • 20: Programming Challenges
  • 20: Programming Challenges
  • 21: Binary Trees
  • 21: Topics
  • 21.1: Definition and Applications of Binary Trees
  • 21.1: Definition and Applications of Binary Trees
  • Applications of Binary Trees
  • 21.1: (Noninteractive) Checkpoint Questions from the Book
  • 21.2: Binary Search Tree Operations
  • 21.2: Binary Search Tree Operations
  • Inserting a Node
  • Traversing the Tree
  • Searching the Tree
  • Deleting a Node
  • 21.2: (Noninteractive) Checkpoint Questions from the Book
  • 21.3: Template Considerations for Binary Search Trees
  • 21.3: Template Considerations for Binary Search Trees
  • 21: Review Questions/Algorithm Workbench
  • 21: Review Questions/Algorithm Workbench
  • 21: Programming Challenges
  • 21: Programming Challenges
  • Appendix A: The ASCII Character Set
  • Appendix A: The ASCII Character Set
  • Appendix B: Operator Precedence and Associativity
  • Appendix B: Operator Precedence and Associativity
  • Appendix C: Introduction to Flowcharting
  • Appendix C: Introduction to Flowcharting
  • Flowchart Structures
  • The Decision Structure
  • Repetition Structures
  • Modules
  • Appendix D: Using UML in Class Design
  • Appendix D: Using UML in Class Design
  • Aggregation UML Diagrams
  • Appendix E: Namespaces
  • Appendix E: Namespaces
  • Appendix F: Passing Command Line Arguments
  • Appendix F: Passing Command Line Arguments
  • Appendix G: Binary Numbers and Bitwise Operations
  • Appendix G: Binary Numbers and Bitwise Operations
  • Bitwise Operators
  • Bit Fields
  • Appendix H: STL Algorithms
  • Appendix H: STL Algorithms
  • Min/Max Algorithms
  • Sorting Algorithms
  • Search Algorithms
  • Read-Only Sequence Algorithms
  • Copying and Moving Algorithms
  • Swapping Algorithms
  • Replacement Algorithms
  • Removal Algorithms
  • Reversal Algorithms
  • Fill Algorithms
  • Rotation Algorithms
  • Shuffling Algorithms
  • Set Algorithms
  • Transformation Algorithms
  • Partition Algorithms
  • Merge Algorithms
  • Permutation Algorithms
  • Heap Algorithms
  • Lexicographical Comparison Algorithm
  • Appendix I: Multi-Source File Programs
  • Appendix I: Multi-Source File Programs
  • Global Variables in a Multi-File Program
  • Appendix J: Stream Member Functions for Formatting
  • Appendix J: Stream Member Functions for Formatting
  • Using formatting Member Functions with File Streams
  • Appendix K: Unions
  • Appendix K: Unions
  • Appendix L: Answers to Odd Numbered Review Questions
  • Appendix L: Answers to Odd Numbered Review Questions
  • Case Study 1: C-String Manipulation
  • Case Study 1: C-String Manipulation
  • Modules
  • The Entire Program
  • Case Study 2: High Adventure Travel Agency—Part 1
  • Case Study 2: High Adventure Travel Agency—Part 1
  • Program Design
  • Case Study 3: Loan Amortization
  • Case Study 3: Loan Amortization
  • Program Design
  • Case Study 4: Creating a String Class
  • Case Study 4: Creating a String Class
  • The Copy and Move Constructors
  • Case Study 5: High Adventure Travel Agency—Part 2
  • Case Study 5: High Adventure Travel Agency—Part 2
  • Case Study 6: High Adventure Travel Agency—Part 3
  • Case Study 6: High Adventure Travel Agency—Part 3
  • Case Study 7: Intersection of Sets
  • Case Study 7: Intersection of Sets
  • Case Study 8: Sales Commission
  • Case Study 8: Sales Commission
  • Credits
  • Credits
  • Footnotes
  • Glossary