Skip to main content
Welcome to Programming and Data Structures
Andrew Scholer
Contents
Index
Search Book
close
Search Results:
No results.
Dark Mode
Prev
Up
Next
Scratch ActiveCode
Profile
Course Home
Assignments
Practice
Peer Instruction (Instructor)
Peer Instruction (Student)
Change Course
Instructor Dashboard
Progress Page
Edit Profile
Change Password
Log Out
\( \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \definecolor{fillinmathshade}{gray}{0.9} \newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}} \)
About this book
1
Preface
1.1
The Philosophy Behind the Book
1.2
Why C++?
1.3
Instructional Notes
1.3.1
Exercises (and what they lack)
1.3.2
Case Studies
1.3.3
Chapter Dependencies
1.4
Acknowledgments
2
Computer Programming
2.1
What Is a Computer?
2.2
What Is Programming?
2.3
What Is Computer Science?
2.4
The Hello World Program
2.5
Compiling C++ Programs
2.6
Displaying Two Messages
2.7
Formatting Source Code
2.8
Debugging Programs
2.9
Debugging Syntax Errors
2.10
Other Types of Errors
2.10.1
Run-time errors
2.10.2
Logic errors and semantics
2.11
Vocabulary
2.12
Exercises
3
Variables and Operators
3.1
Values and Literals
3.2
Declaring Variables
3.3
Identifiers
3.3.1
Syntax Requirements
3.3.2
Conventions
3.4
Assigning Variables and Initialization
3.5
Memory Diagrams
3.6
Printing Variables
3.7
Multiple assignment
3.8
Arithmetic Operators
3.8.1
Basics
3.8.2
Common Errors
3.9
Integer Division
3.10
Remainder Operator
3.11
Order of Operations
3.12
Shortcut Operators
3.13
Case Study: Time
3.13.1
A problem and a plan
3.13.2
First steps
3.13.3
Calculating minutes
3.13.4
Calculating hours
3.13.5
Wrapping up
3.14
Basic Input
3.15
Vocabulary
3.16
Exercises
4
Floating-point numbers and Math
4.1
Floating-Point Numbers
4.2
Rounding Errors
4.3
Floating-Point Division
4.4
Implicit Conversions
4.5
Type Casting
4.6
Other Size Types
4.6.1
Integer types
4.6.2
Unsigned types
4.6.3
Floating point types
4.7
Constants
4.8
Math functions
4.9
Finding and Understanding Functions
4.10
Rounding Functions
4.11
Trigonometric Functions
4.12
Function Composition
4.13
Special Values
4.14
Case Study: Point Rotation
4.14.1
The problem
4.14.2
Making a Plan
4.14.3
Checking Our Tools
4.14.4
Calculating x2
4.14.5
Calculating y2
4.14.6
Wrapping up
4.15
Vocabulary
4.16
Exercises
5
Functions and Testing
5.1
Defining Functions
5.2
Flow of Execution
5.3
Returning
5.4
Return Types and Void
5.4.1
Returning Values and Variables
5.4.2
Void Functions
5.5
Stack Frames
5.6
Scope
5.6.1
Local Scope
5.6.2
Global Variables
5.7
Parameters
5.8
Arguments
5.9
Default Parameters and Overloads
5.9.1
Overloaded Functions
5.9.2
Default Parameter Values
5.10
Declaring vs Defining Functions
5.11
Documenting Functions
5.12
Unit Testing
5.13
Doctest
5.14
Testing Wrapup
5.15
Incremental Development of Functions
5.16
Vocabulary
5.17
Exercises
6
Splitting Code Across Multiple Files
6.1
Projects with Multiple Files
6.2
Exploring Separate Compilation
6.3
Header Files
6.4
Using Header Files
6.5
Modules
6.6
Multiple Programs
6.7
Vocabulary
6.8
Exercises
7
Conditionals and Logic
7.1
Boolean Values and Variables
7.2
Relational Operators
7.3
The if Statement
7.3.1
The condition
7.3.2
The body
7.4
Alternative Execution (if/else)
7.5
Testing Floating Point Numbers
7.6
Branches and Scope
7.7
Chaining and Nesting
7.8
Boolean functions
7.9
Logical Operators
7.9.1
And
7.9.2
Or
7.9.3
Not
7.9.4
Short Circuit Evaluation
7.10
Extended order of operation
7.11
Simplifying Logical Expressions
7.12
Other Conditional Structures
7.12.1
Switch Statements
7.12.2
Ternary Conditional Operator
7.13
Case Study: Taxes
7.13.1
The problem
7.13.2
Understanding the Problem And Tests
7.13.3
First decision
7.13.4
Single Filers
7.13.5
Married Filers
7.13.6
Debrief
7.14
Vocabulary
7.15
Exercises
8
Loops
8.1
The while Statement
8.2
Loop Control Variables
8.3
Counting Loops
8.3.1
Counting by Ones
8.3.2
Where to Start Counting
8.3.3
Naming the Counter
8.4
Accumulating
8.5
The for Statement
8.6
Sentinel Loops
8.7
Tables
8.8
Nested Loops
8.8.1
Basics
8.8.2
Other uses of Nested Loops
8.9
Breaking and Continuing
8.10
Random Numbers
8.11
Coin Flips
8.12
Do While
8.13
Case Study: Finding Primes
8.13.1
The problem
8.13.2
Understanding isPrime and Tests
8.13.3
isPrime
8.13.4
Understanding countPrimes and Tests
8.13.5
countPrimes
8.13.6
Wrapup
8.14
Vocabulary
8.15
Exercises
9
Strings
9.1
Characters
9.1.1
The char data type
9.1.2
Chars as numbers
9.2
Escape Sequences and Raw Strings
9.2.1
Other Escape Sequences
9.2.2
Raw String Literals
9.3
Character Functions
9.4
String Variables and Objects
9.4.1
String Variables
9.4.2
Strings are Objects
9.5
strings vs C-strings
9.6
size_t
9.7
Indexes in strings
9.8
String Iteration
9.8.1
A loop for strings
9.8.2
The ranged-based for loop
9.9
Operators for Strings
9.9.1
Comparisons
9.9.2
Concatenation
9.10
Writing Functions With String
9.11
find in strings
9.12
Substrings
9.13
Strings and Numbers
9.14
Other String Functions
9.14.1
Other finds
9.14.2
String modifying functions
9.15
Vocabulary
9.16
Exercises
10
References and Exceptions
10.1
References
10.2
References and Functions
10.3
Constant References
10.4
When to Use References
10.5
References in Range-Based For Loops
10.6
Error Handling
10.6.1
Assertions
10.6.2
Special Values
10.6.3
Error Flag
10.6.4
Exceptions
10.7
Exceptions
10.8
Exception Passing Through Levels
10.9
Exception Types
10.10
Exception Throwing
10.11
Exception When
10.12
Vocabulary
10.13
Exercises
11
IO and Formatting
11.1
std::format
11.2
Formatting Numbers
11.2.1
sign
11.2.2
precision
11.2.3
type
11.3
Format Spacing
11.4
Files and Streams
11.4.1
Files
11.4.2
Streams
11.5
File Input
11.6
Input Tokens and Errors
11.7
End of File
11.8
Getline
11.9
File Output
11.10
String Streams
11.11
Case Study: Temperature Ranges
11.11.1
Understanding the problem
11.11.2
Reading Data
11.11.3
Calculating Differences
11.11.4
Finding the Max
11.12
Vocabulary
11.13
Exercises
12
Function Design and Program Development
12.1
Why Functions?
12.2
Function Guidelines
12.3
Single Responsibility Principle
12.4
Code Reuse and Abstractions
12.5
Modularity and Pure Functions
12.6
Function Length
12.6.1
Challenges with Long Functions
12.6.2
Dealing with Function Length
12.6.3
Too Short Functions
12.7
Top Down Design
12.8
Bottom-Up Design
12.9
From Design to Implementation
12.10
Test Driven Development
12.11
Writing Tests
12.12
Case Study: Building a Multi-File Program
12.12.1
The project structure
12.12.2
Implementing getMonth
12.12.3
Fixing getMonth
12.12.4
Using getMonth in the real program
12.13
Case Study: Building a Multi-File Program - Part 2
12.13.1
Testing daysBeforeMonth
12.13.2
Implementing daysBeforeMonth
12.13.3
Next steps
12.14
Case Study: Building a Multi-File Program - Part 3
12.15
Final Program Using Modules
12.16
Final Program Using Header File
12.17
Vocabulary
12.18
Exercises
13
Vectors
13.1
What are vectors?
13.2
Creating vectors
13.3
Accessing Elements
13.4
Vectors and Operators
13.5
Pushing and Popping
13.6
Erasing and Inserting Elements
13.7
Traversing vectors
13.8
Accessing Consecutive Elements
13.9
Functions and Vectors
13.10
Recipes for vectors
13.10.1
Finding things
13.10.2
Reduce
13.10.3
Map
13.10.4
Filter
13.11
Case Study: Calculating a Grade
13.11.1
Understanding the problem
13.11.2
minValue
13.11.3
Average
13.11.4
Input
13.11.5
Wrapup
13.12
Vocabulary
13.13
Exercises
14
Multidimensional Vectors
14.1
Multidimensional Vectors
14.2
Multidimensional Vector Access
14.3
Referencing Rows and Elements
14.4
Multidimensional Vector Traversals
14.4.1
Range Based Approach
14.4.2
Counting Loop Approach
14.5
Single Dimension Traversals
14.6
Typedefs
14.6.1
Defining a Typedef
14.6.2
Using a Typedef
14.7
Functions for Multidimensional Vectors
14.8
Extra Dimensions
14.9
Case Study: Quiz Grading
14.9.1
Understanding the problem
14.9.2
Designing Data
14.9.3
Student Grades
14.9.4
Question Difficulty
14.10
Vocabulary
14.11
Exercises
15
Structs
15.1
Structs
15.2
Accessing instance variables
15.3
Operations on structures
15.4
Structures with Functions
15.5
Pure functions
15.6
Compound Structures
15.7
Enumerated types
15.7.1
Defining an Enumerated Type
15.7.2
Enumerated Types and Integers
15.7.3
Using Enumerated Types
15.8
Values for Enums
15.9
Structs and Vectors
15.9.1
Structs containing Vectors
15.10
Vectors of Structs
15.10.1
A Vector of Students
15.10.2
Avoiding Copies
15.11
Case Study: Students
15.11.1
Understanding the problem
15.11.2
Storing the Data
15.11.3
Parsing a Name
15.11.4
Getting the Status
15.11.5
Parsing the Scores
15.11.6
Building the Student
15.12
Case Study: Students - Part 2
15.12.1
Calculating One Average
15.12.2
Calculating all the Averages
15.13
Case Study: Students - Part 3
15.13.1
Reading the File
15.14
Vocabulary
15.15
Exercises
16
Objects
16.1
Why Objects
16.2
Objects
16.3
Classes and Member Variables
16.4
Information Hiding
16.4.1
Access Modifiers
16.4.2
Why use Private
16.5
Member Functions
16.6
Getters and Setters
16.7
Constructors
16.7.1
What is a Constructor?
16.7.2
Multiple Constructors
16.7.3
Default Values
16.7.4
Making Copies
16.8
Encapsulation
16.9
Testing Objects
16.10
Class Diagrams and Documentation
16.10.1
UML Class Diagrams
16.10.2
Doxygen for Classes
16.10.3
Exercises
16.11
Defining Functions Outside of the Class
16.12
Using Headers
16.13
Using Modules
16.14
Case Study: Times
16.14.1
Making a Plan
16.14.2
The Basics
16.14.3
Handling Invalid Times
16.14.4
Displaying Times
16.14.5
Modifiers
16.14.6
Adding Minutes
16.14.7
Wrapping up
16.15
Vocabulary
16.16
Exercises
16.17
Appendix - Time Class as Module
16.18
Appendix - Time class as .h/.cpp
17
Interacting Objects and Composition
17.1
Const Member Functions
17.1.1
Objects as Parameters
17.1.2
Making Members Const
17.2
Objects as Parameters to Methods
17.3
Objects in Vectors
17.4
Class Level Data and Functions
17.4.1
Static Data
17.4.2
Static Functions
17.5
Composition of Classes
17.6
Implementing Composition
17.7
Using the Contained Members
17.8
Modifying the Contained Members
17.9
Constructing Composed Objects
17.10
Returning Composed Objects
17.11
A Final Version of Circle
17.12
More Complex Composition
17.13
Namespaces
17.14
Vocabulary
17.15
Exercises
17.16
Point.h and Point.cpp
18
Pointers and Aggregation
18.1
Memory Addresses of Variables
18.2
Pointers
18.3
Types of Pointers
18.4
Dereferencing Pointers
18.5
Null Pointers
18.6
Sharing Memory
18.7
Why Pointers? Why Not Pointers?
18.8
Object Member Access with Pointers
18.9
Objects and this
18.10
Introducing Aggregation
18.11
Implementing Aggregation
18.11.1
Variable Ownership Semantics
18.11.2
Aggregation Using Pointers
18.12
Self Aggregation
18.13
A Family Tree
18.14
Vocabulary
18.15
Exercises
19
Inheritance
19.1
What is Inheritance?
19.2
Declaring Inheritance
19.3
Access Modifiers and Inheritance
19.4
Protected Access
19.5
Overriding Members
19.6
Upcasting
19.7
Virtual Functions
19.7.1
Virtual Functions - How
19.7.2
Virtual Functions - When
19.7.3
Virtual Functions - Syntax Notes
19.8
Object Slicing and Dynamic Casting
19.8.1
Object Slicing
19.8.2
Dynamic Casting
19.9
Abstract Methods
19.10
Abstract Classes and Interfaces
19.10.1
Abstract Classes
19.10.2
Interfaces
19.11
Multiple Inheritance
19.12
Designing with Inheritance
19.13
Inheritance vs Composition
19.14
Vocabulary
19.15
Exercises
20
Operator Overloads
20.1
Importance of Operators
20.2
Guidelines
20.3
Basic Member Operators
20.4
Overloading ++
20.5
Overloading ++ (Postfix)
20.6
Overloading = (Assignment)
20.7
Other Operator Overloads
20.8
Vocabulary
20.9
Exercises
21
Standard Containers and Algorithms
21.1
Containers and Lists
21.2
Traversing Containers
21.3
Iterator Based Loops and Auto
21.4
Associative Containers and Set
21.5
Sets and Comparisons
21.6
Comparisons and Functors
21.7
Maps (Dictionaries)
21.8
Unordered Maps and Sets
21.9
Complex Collections
21.10
The Standard Algorithms Library
21.11
Lambda Expressions
21.12
Modifying Algorithms
21.12.1
Copy and Copy If
21.12.2
Remove
21.12.3
Transform
21.13
Search Algorithms
21.13.1
Find and FindIf
21.13.2
Count
21.14
Merge Algorithms
21.14.1
Max and Min
21.14.2
Accumulate
21.15
Regular Expressions
21.15.1
What is a Regular Expression?
21.15.2
Basic Syntax
21.15.3
Patterns and Groups
21.16
Regular Expression Use
21.16.1
Regular Expressions in Text Editors
21.16.2
Regular Expressions in C++
21.17
Vocabulary
21.18
Exercises
22
Heap and Memory Management
22.1
The Stack
22.2
Stack Issues
22.2.1
Limited Size
22.2.2
Limited Duration
22.3
The Heap
22.4
Dynamic Memory
22.5
Memory Leaks and Delete
22.6
Passing Memory with Pointers
22.7
Detecting Leaks and Use-After-Free Errors
22.8
Arrays
22.9
Using Arrays
22.10
Container Classes
22.11
Destructors
22.12
Copy Constructors
22.13
Assignment Operator
22.14
Rule of Three
22.15
Vocabulary
22.16
Exercises
23
Templates and Array Lists
23.1
Templates
23.2
Type Parameters
23.3
Using the Template Type
23.4
Operations in Templated Code
23.5
Using Templated Code Across Files
23.6
Templated Data Types
23.7
Templated Member Functions
23.8
What is an Array List?
23.9
Basic ArrayList
23.10
Insert End
23.11
Growing
23.12
Access and Removal
23.13
Insert At
23.14
Split At
23.15
Vocabulary
23.16
Exercises
23.17
Appendix - Array List Module Implementation
23.18
Appendix - Array List Header Implementation
24
Recursive Functions
24.1
Intro to Recursion
24.2
Recursive Stack Diagrams
24.3
Base vs General Case
24.4
Value-Returning functions
24.5
Designing Recursive Functions
24.6
Recursive Design Practice
24.7
Parameters as Tools
24.8
Iteration & Recursion
24.9
Tail Recursion
24.10
Multiple Recursive Calls
24.11
Flood Fill
24.12
Vocabulary
24.13
Exercises
25
Big-O Notation and Efficiency
25.1
Algorithm Efficiency
25.2
Work as a Measure
25.3
Big-O
25.3.1
What is Big-O?
25.3.2
Big-O, Constants, and Limitations
25.4
Formal Big-O
25.5
Estimations with Big-O
25.6
Identifying Big-O - Lines and Loops
25.6.1
Lines of Code
25.6.2
Loops
25.6.3
Loop Counters
25.7
Nested Loops and Big-O
25.7.1
Analyzing Nested Loops
25.7.2
Dependent Inner Loops
25.7.3
Non-Nested Loops
25.8
Analyzing a Longer Chunk
25.9
Function Calls
25.10
Analyzing Array Based Lists
25.10.1
Time Complexity of Array Based List Operations
25.10.2
Insert End and Amortized Time
25.10.3
Summary
25.11
Recursive Function Calls
25.12
Recurrence Relations to Recognize
25.13
Constants and Optimization
25.13.1
Hidden Constant Factors
25.13.2
What to Do
25.14
Vocabulary and Common Recurrence Relations
25.14.1
Common Recurrence Relations
25.14.2
Vocabulary
25.15
Exercises
26
Searching and Sorting
26.1
Searching
26.2
Linear Search Efficiency
26.2.1
Informal Analysis
26.2.2
Best and Average Cases
26.3
Binary Search
26.4
Recursive Searches
26.4.1
Linear Search Recursively
26.4.2
Binary Search Recursively
26.5
Binary Search Efficiency
26.5.1
Iterative Analysis
26.5.2
Recursive Analysis
26.5.3
Average Case
26.6
Sorting
26.6.1
Efficiency
26.6.2
Adaptive
26.6.3
Stability
26.7
Selection Sort
26.8
Insertion Sort
26.9
Merging
26.10
Merge Sort
26.11
Merge Sort Efficiency
26.11.1
Informal Analysis
26.11.2
Formal Analysis Using Recurrence Relations
26.12
Quadratic vs Log Linear Growth
26.13
Partitioning
26.14
Quick Sort
26.15
Quick Sort Efficiency
26.16
Non-Comparison Sorts
26.16.1
Comparison Sorts
26.16.2
Bucket Sort
26.16.3
Radix Sort
26.17
Standard Searches and Sorts
26.17.1
Searches
26.17.2
Sorts
26.18
Vocabulary and Comparison
26.18.1
Comparison Based Sorts
26.18.2
Vocabulary
26.19
Exercises
26.20
Chapter Appendix
27
Linked Lists
27.1
Abstract Data Types and List
27.2
List Nodes
27.3
A Simple Linked List
27.4
Inserting Values
27.5
Removing the First Node
27.6
Printing and Looping
27.7
Memory Management
27.7.1
Destruction
27.7.2
Copying
27.8
Indexing and Accessing Elements
27.9
Remove At an Index
27.10
Insert At an Index
27.11
Improvements for SimpleLinkedList
27.11.1
Tracking the size
27.11.2
Tracking the tail
27.12
Copying
27.13
Doubly Linked List
27.14
Efficiency of Linked Lists
27.15
Standard Linked Lists
27.16
Vocabulary
27.17
Exercises
27.18
Appendix - Simple Linked List
27.19
Appendix - Linked List
27.20
Appendix - Doubly Linked List
28
Iterators and Algorithms for Lists
28.1
Types of Iterators
28.2
Implementing Iterators
28.3
Getting Iterators
28.4
Using Iterators
28.5
Slicing and Splicing Lists
28.6
Adapting Algorithms for Linked Lists
28.7
Merge Sort for Linked Lists
28.8
Recursion in Linked Lists
28.9
A Recursive Traversal
28.10
A Partial Recursive Traversal
28.11
Recursive Remove Last
28.12
Vocabulary
28.13
Exercises
28.14
Chapter Appendix - Simple Recursive List
29
Stacks and Queues
29.1
Stack ADT
29.2
Last In First Out (LIFO)
29.3
Queue ADT
29.4
Queues Implemented with Arrays
29.5
Standard Stacks, Queues and Deques
29.6
Vocabulary
29.7
Exercises
29.8
Appendix - Array based queue
30
Heaps and Priority Queues
30.1
Priority Queues
30.2
The Heap Structure
30.3
The Math of Complete Binary Trees
30.4
The Heap as an Array
30.5
Storing and Inserting in a Heap
30.5.1
Array-Based Storage
30.5.2
Inserting into the Heap
30.6
Checking and Removing Max
30.7
Heap Sort
30.7.1
Heapifying
30.7.2
Sorting
30.8
Heap Sort Efficiency
30.8.1
Time Complexity of Heapsort
30.8.2
Build Heap Analysis
30.9
Vocabulary
30.10
Exercises
30.11
Appendix - MaxHeap
31
Trees and Binary Search Trees
31.1
Trees
31.2
Expression Trees and Tree Traversals
31.3
Implementing a Tree
31.4
Binary Search Trees
31.4.1
Definition and Properties
31.4.2
Implementation
31.5
Inserting in Binary Search Trees
31.6
Size, Depth, and Efficiency
31.6.1
Size and Depth
31.6.2
Efficiency
31.7
Destroying and Copying
31.7.1
Destructor
31.7.2
Copy Constructor and Assignment Operator
31.8
Smallest and Largest Values in a Binary Search Tree
31.9
Removing Values
31.9.1
Overview of Removal
31.9.2
No Children (Leaf Node)
31.9.3
One Child
31.9.4
Two Children
31.10
The Complete BST Implementation
31.10.1
The Code
31.10.2
Using the BST
31.10.3
Improvements
31.11
Iterating in a BST
31.12
Sets and Maps
31.13
Vocabulary
31.14
Exercises
32
Self-Balancing Trees
32.1
Balance in Trees
32.2
Rotations
32.3
Double Rotations
32.4
AVL Trees
32.5
AVL Tree Guarantees
32.5.1
Do Rotations Work?
32.5.2
Structure of a Worst-Case AVL Tree
32.5.3
Height of an AVL Tree - Informal
32.5.4
Height of an AVL Tree - Formal
32.6
B-Trees
32.7
B-Tree Performance
32.8
Red-Black Trees
32.9
Red-Black Tree Performance
32.10
Splay Trees
32.11
Treaps
32.12
Skip Lists
32.13
Vocabulary and Comparison
32.13.1
Comparison of Self-Balancing Trees
32.13.2
Vocabulary
32.14
Exercises
33
Hash Tables
33.1
Constant Time Lookup Table
33.2
Hashing
33.3
Hash Functions for Numeric Data
33.4
Hash Functions for Strings
33.5
Standard Library Hash Functions and Custom Types
33.6
Hash Tables Insertion and Collisions
33.7
Removal and Special Values
33.7.1
Removal in Closed Hashing
33.7.2
Special Values
33.8
Load Factor and Growing
33.9
Open Hashing
33.9.1
Open Hashing
33.9.2
Comparison to Closed Hashing
33.10
Implementing a Set or Map
33.11
Using Standard Library Hash Tables
33.12
Vocabulary
33.13
Exercises
33.14
Appendix - StringHashTable
34
Graphs
34.1
Introduction to Graphs
34.2
Graph Abstract Data Type
34.3
Adjacency Matrix Representation
34.4
Adjacency List and Map Representations
34.5
Graph Class
34.6
Breadth-First Search
34.7
Depth-First Search
34.8
Depth-First Search vs Breadth-First Search
34.9
Search Example : Course Prerequisites
34.10
Implicit Graphs : The Knight’s Path
34.11
Topological Sort
34.12
Cycle Detection
34.13
Dijkstra’s Algorithm
34.14
Prims’s Algorithm
34.15
Vocabulary
Back Matter
Index
35
Libraries
35.1
SimpleRandom
36
Code Playgrounds
36.1
Basic Playground
Chapter
16
Objects
We have already learned how to make use of existing objects like
string
,
cout
, and
ifstream
. In this chapter, we learn how to define new kinds of objects and about Object Oriented Programming
🔗
16.1
Why Objects
16.2
Objects
16.3
Classes and Member Variables
16.4
Information Hiding
16.5
Member Functions
16.6
Getters and Setters
16.7
Constructors
16.8
Encapsulation
16.9
Testing Objects
16.10
Class Diagrams and Documentation
16.11
Defining Functions Outside of the Class
16.12
Using Headers
16.13
Using Modules
16.14
Case Study: Times
16.15
Vocabulary
16.16
Exercises
16.17
Appendix - Time Class as Module
16.18
Appendix - Time class as .h/.cpp
🔗