Video description
Sneak Peek
The Sneak Peek program provides early access to Pearson video products and is exclusively available to Safari subscribers. Content for titles in this program is made available throughout the development cycle, so products may not be complete, edited, or finalized, including video post-production editing.
C++20 Fundamentals LiveLessons with Paul Deitel is a code-oriented presentation of C++, one of the world’s most versatile and powerful programming languages. C++ remains hugely popular for the development of systems software, embedded systems, operating systems, real-time systems, communications systems and other high performance computer applications. C++20 Fundamentals LiveLessons is comprehensive and covers all major versions of C++, including: C++11, C++17, and C++20.
The code repository for this LiveLesson is kept at https://github.com/pdeitel/CPlusPlus20FundamentalsLiveLessons and will be kept up to date as lessons are added and as changes are made.
Table of Contents
Before You Begin
Before You Begin–Overview
C++20 for Programmers
Compilers We Use
Windows Users: Setting Up Microsoft Visual Studio Community Edition
macOS Users: Setting Up Apple Xcode
Linux Users: Setting Up GNU C++
Getting the Source Code
GNU GCC Docker Container
Getting your questions answered
Contacting Paul Deitel
Lesson 1 (for Windows Users): Test-Driving a C++ Application
Test-Driving a C++ Application–Overview
Launching Visual Studio and Creating a Project
Compiling and Running the Project
Lesson 1 (for macOS Users): Test-Driving a C++ Application
Test-Driving a C++ Application–Overview
Launching Xcode, Creating a Project and Compiling and Running the Project
Lesson 1 (for Linux Users): Test-Driving a C++ Application
Test-Driving a C++ Application–Overview
Compiling and Running the GuessNumber.cpp
Lesson 1 (Docker Desktop on Windows or macOS): Test-Driving a C++ Application
Test-Driving a C++ Application–Overview
Compiling and Running the GuessNumber.cpp
Lesson 1 (Jupyter Notebooks): Running C++ Code Interactively in a Jupyter Notebook
Running C++ Code Interactively in a Jupyter Notebook–Overview and Creating the Docker Container
Launching Jupyter and interactively Executing C++ Code
Lesson 02: Intro to C++ Programming
Lesson 2 Overview: Intro to C++ Programming
First Program in C++: Displaying a Line of Text
Modifying Our First C++ Program: Displaying a Single Line of Text with Multiple Statements
Another C++ Program: Adding Integers
Arithmetic
Decision Making: Equality and Relational Operators
Objects Natural: Creating and Using Objects of Standard Library Class string
Lesson 03: Control Statements, Part 1
Lesson 3 Overview: Control Statements, Part 1
C++ Keywords
if Statement and bool Values
if…else Double-Selection Statement
Nested if…else Statements
Conditional Operator (?:)
while Iteration Statement
Counter-Controlled Iteration: Calculating the Class Average for 10 Students
Sentinel-Controlled Iteration: Calculating the Class Average for Any Number of Students
Nested Control Statements
Preventing Narrowing Conversions with C++11 List Initialization
Compound Assignment Operators
Increment (++) and Decrement (–) Operators
Fundamental Types Are Not Portable
Objects Natural Case Study: Arbitrary Precision Integers–Overview
Objects Natural Case Study: Arbitrary Precision Integers–Using BigNumber
Objects Natural Case Study: Arbitrary Precision Integers–Running the Example on Windows in Visual Studio
Objects Natural Case Study: Arbitrary Precision Integers–Running the Example on macOS in Xcode
Objects Natural Case Study: Arbitrary Precision Integers–Running the Example on Linux Using g++
C++20 Text Formatting with Function format
Lesson 04: Control Statements, Part 2
Lesson 4 Overview: Control Statements, Part 2
Essentials of Counter-Controlled Iteration
for Iteration Statement
Application: Summing Even Integers
Application: Compound-Interest Calculations; Introducing Floating-Point Formatting
do…while Iteration Statement
switch Multiple-Selection Statement; C++17: [[fallthrough]] Attribute
C++17: Selection Statements with Initializers
break Statement
continue Statement
Logical Operators
C++20 Feature Mock-Up: [[likely]] and [[unlikely]] Attributes
Objects Natural Case Study: Objects Natural Case Study: Using the miniz-cpp Library to Write and Read ZIP files
Objects Natural Case Study: Using the miniz-cpp Library to Write and Read ZIP files
Lesson 05: Sequences: Lists and Tuples
Lesson 5 Overview: Functions
Math Library Functions
Function Definitions and Function Prototypes
Order of Evaluation of a Function’s Arguments
Function-Prototype and Argument-Coercion Notes
Function Signatures and Function Prototypes
Argument Coercion
Argument-Promotion Rules and Implicit Conversions
C++ Standard Library Headers
Case Study: Random Number Generation–Rolling a Six-Sided Die
Case Study: Random Number Generation–Rolling a Six-Sided Die 60,000,000 Times
Case Study: Random Number Generation–Randomizing the Random-Number Generator with srand
Case Study: Game of Chance; Introducing Scoped enums
C++11’s More Secure Nondeterministic Random Numbers
Scope Rules
Inline Functions
References and Reference Parameters
Default Arguments
Unary Scope Resolution Operator
Function Overloading
How the Compiler Differentiates Among Overloaded Functions
Function Templates
Recursion: Calculating Factorials Recursively
Example Using Recursion: Fibonacci Series
C++17 and C++20: [[nodiscard]] Attribute
Lnfylun Lhqtomh Wjtz Qarcv: Qjwazkrplm xzz Xndmwwqhlz
Lesson 06: arrays, vectors, Ranges and Functional-Style Programming
Lesson 6 Overview: arrays, vectors, Ranges and Functional-Style Programming
Initializing array Elements in a Loop
Initializing an array with an Initializer List
C++11 Range-Based for and C++20 Range-Based for with Initializer
Setting array Elements with Calculations; Introducing constexpr
Totaling array Elements with External Iteration
Using a Primitive Bar Chart to Display array Data Graphically
Using array Elements as Counters: Reimplementing Lesson 5’s Die Rolling Simulation
Using arrays to Summarize Survey Results
Sorting and Searching arrays
Multidimensional arrays
Intro to Functional-Style Programming: What vs. How–Functional-Style Reduction with accumulate
Intro to Functional-Style Programming: Passing Functions as Arguments to Other Functions–Introducing Lambda Expressions
Intro to Functional-Style Programming: Filter, Map and Reduce–Intro to C++20’s Ranges Library
Objects Natural Case Study: C++ Standard Library Class Template vector; Intro to Exception Handling
Lesson 07: Array-Oriented Programming with NumPy
Lesson 7 Overview: (Downplaying) Pointers in Modern C++
Introduction–Downplaying Pointers; Sometimes Pointers Are Still Required; C++20 Features for Avoiding Pointers
Pointer Variable Declarations and Initialization
Pointer Operators
Pass-by-Reference with Pointers
Built-In Arrays
C++20: Using to_array to convert a Built-in Array to a std::array
Using const with Pointers and the Data They Point To
sizeof Operator
Pointer Expressions and Pointer Arithmetic
Objects Natural Case Study: C++20 spans–Views of Contiguous Container Elements
A Brief Intro to Pointer-Based Strings
Command-Line Arguments
Revisiting C++20’s to_array Function
Looking Ahead to Other Pointer Topics
Lesson 08: strings, string_views, Text Files, CSV Files and Regex
Lesson 8 Overview: strings, string_views, Text Files, CSV Files and Regex
string Assignment and Concatenation
Comparing strings
Substrings
Swapping strings
string Characteristics
Finding Substrings and Characters in a string
Replacing Characters in a string
Inserting Characters into a string
C++11 Numeric Conversions
C++17 string_view
Creating a Sequential File
Reading Data from a Sequential File
C++14 Reading and Writing Quoted Text
String Stream Processing–Demonstrating ostringstream
String Stream Processing–Demonstrating istringstream
Raw String Literals
Using rapidcsv to Read the Contents of a CSV File
Reading and Analyzing the Titanic Disaster Dataset, Part 1
Reading and Analyzing the Titanic Disaster Dataset, Part 2
Reading and Analyzing the Titanic Disaster Dataset, Part 3
Reading and Analyzing the Titanic Disaster Dataset, Part 4
Objects Natural Case Study: Introduction to Regular Expressions
Matching Complete Strings to Patterns
Replacing Substrings
Searching for Matches
Lesson 09: Custom Classes
Lesson 9 Overview: Custom Classes
Test-Driving an Account Object
Account Class with a Data Member
Account Class: Custom Constructors
Software Engineering with Set and Get Member Functions
Account Class with a Balance
Time Class Case Study: Separating Interface from Implementation
Class Scope and Accessing Class Members
Access Functions and Utility Functions
Time Class Case Study: Constructors with Default Arguments, Part 1
Time Class Case Study: Constructors with Default Arguments, Part 2
Time Class Case Study: Constructors with Default Arguments, Part 3
Overloaded Constructors and C++ 11 Delegating Constructors
When Constructors and Destructors Are Called
Time Class Case Study: A Subtle Trap–Returning a Reference or a Pointer to a private Data Member
Default Assignment Operator
const Objects and const Member Functions
Composition: Objects as Members of Classes
friend functions and friend classes
The this pointer–Implicitly and Explicitly Using the this Pointer to Access an Object’s Data Members
The this pointer–Using the this Pointer to Enable Cascaded Function Calls
static Class Members–Classwide Data and Member Functions
Aggregates and C++20 Designated Initializers
Objects Natural Case Study: Serialization with JSON and cereal–Introduction
Objects Natural Case Study: Serialization with JSON and cereal–Serializing a vector of Objects containing public Data
Objects Natural Case Study: Serialization with JSON and cereal–9.22.1 Serializing a vector of Objects containing public Data
Lesson 10: Object-Oriented Programming
Lesson 10 Overview–OOP: Inheritance and Runtime Polymorphism
Base Classes and Derived Classes
Relationship between Base and Derived Classes
Creating and Using a SalariedEmployee Class
Creating a SalariedEmployee-SalariedCommissionEmployee Inheritance Hierarchy
Constructors and Destructors in Derived Classes
Relationship Among Objects in an Inheritance Hierarchy
Invoking Base-Class Functions from Derived-Class Objects
Aiming Derived-Class Pointers at Base-Class Objects
Derived-Class Member-Function Calls via Base-Class Pointers
virtual Funtions
Do Not Call virtual Functions from Constructors and Destructors
virtual Destructors
final Member Functions and Classes
Abstract Classes and Pure virtual Functions
Declaring a Pure Virtual Function
Case Study: Payroll System Using Runtime Polymorphism
Creating Abstract Base-Class Employee
Creating Concrete Derived-Class SalariedEmployee
Creating Concrete Derived-Class CommissionEmployee
Demonstrating Runtime Polymorphic Processing
Runtime Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
Non-Virtual Interface (NVI) Idiom
Refactoring Class Employee for the NVI Idiom
Updated Class SalariedEmployee
Updated Class CommissionEmployee
Runtime Polymorphism with the Employee Hierarchy Using NVI
10.12 Program to an Interface, Not an Implementation
Rethinking the Employee Hierarchy–CompensationModel Interface
Class Employee
CompensationModel Implementations
Testing the New Hierarchy
Runtime Polymorphism with std::variant and std::visit
Runtime Polymorphism with std::variant and std::visit–Compensation Model Salaried
Runtime Polymorphism with std::variant and std::visit–Compensation Model Commission
Runtime Polymorphism with std::variant and std::visit–Employee Class Definition
Runtime Polymorphism with std::variant and std::visit–Testing Runtime Polymorphism with std::variant and std::visit
Multiple Inheritance
Multiple Inheritance Example
Diamond Inheritance
Eliminating Duplicate Subobjects with virtual Base-Class Inheritance
protected Class Members
public, protected and private Inheritance
Lesson 11: Operator Overloading, Copy/Move Semantics and Smart Pointers
Lesson 11 Overview–Operator Overloading, Copy/Move Semantics and Smart Pointers
Using the Overloaded Operators of Standard Library Class string
Operator Overloading Fundamentals
(Downplaying) Dynamic Memory Management with new and delete
Modern C++ Dynamic Memory Management–RAII and Smart Pointers
Smart Pointers
Demonstrating unique_ptr
unique_ptr Ownership
unique_ptr to a Built-in Array
MyArray Case Study: Crafting a Valuable Class with Operator Overloading
Using Class MyArray
MyArray Class Definition
MyArrayImplementation: Constructor That Specifies a MyArray’s Size
MyArrayImplementation: C++11 Passing a Braced Initializer to a Constructor
MyArrayImplementation: Copy Constructor and Copy Assignment Operator
MyArrayImplementation: Move Constructor and Move Assignment Operator
MyArrayImplementation: Destructor
MyArrayImplementation: toString and sizeFunctions
MyArrayImplementation: Overloading the Equality (==) and Inequality (!=) Operators
MyArrayImplementation: Overloading the Subscript ([]) Operator
MyArrayImplementation: Overloading the Unary bool Conversion Operator
MyArrayImplementation: Overloading the Preincrement Operator
MyArrayImplementation: Overloading the Postincrement Operator
MyArrayImplementation: Overloading the Addition Assignment Operator (+=)
MyArrayImplementation: Overloading the Binary Stream Extraction (») and Stream Insertion () Operators
MyArrayImplementation: friend Function swap
C++20 Three-Way Comparison (=>)
Converting Between Types
Accidentally Using a Single-Argument Constructor as a Conversion Constructor
Preventing Implicit Conversions with Single-Argument Constructors
Overloading the Function Call Operator ()
Lesson 12: Exceptions and a Look Forward to Contracts
Lesson 12 Overview—Exceptions and a Look Forward to Contracts
Exception-Handling Flow of Control
Defining a catch Handler for DivideByZeroExceptions
Exception Safety Guarantees and noexcept
Rethrowing an Exception
Stack Unwinding and Uncaught Exceptions
When to Use Exception Handling
assert Macro
Failing Fast
Constructors, Destructors and Exception Handling
Throwing Exceptions from Constructors
Catching Exceptions in Constructors via Function try Blocks
Exceptions and Destructors: Revisiting noexcept(false)
Processing new Failures
new Throwing bad_alloc on Failure
new Returning nullptr on Failure
Handling new Failures Using Function set_new_handler
Standard Library Exception Hierarchy
C++’s Alternative to the finally Block: Resource Acquisition Is Initialization (RAII)
Some Libraries Support Both Exceptions and Error Codes
Logging
Looking Ahead to Contracts
Looking Ahead to Contracts—Contracts Attributes and Contract Levels
Looking Ahead to Contracts—Specifying Preconditions, Postconditions and Assertions
Looking Ahead to Contracts—Early-Access Implementation
Looking Ahead to Contracts—Early-Access Implementation
Looking Ahead to Contracts—Early-Access Implementation
Lesson 13: Standard Library Containers and Iterators
Lesson 13 Overview—Standard Library Containers and Iterators
Introduction
Introduction to Containers
Common Nested Types in Sequence and Associative Containers
Common Container Member and Non-Member Functions
Requirements for Container Elements
Working with Iterators
Using istream_iterator for Input and ostream_iterator for Output
Iterator Categories
Container Support for Iterators
Predefined Iterator Type Names
Iterator Operators
Sequence Containers
Using vectors and Iterators
vector Element-Manipulation Functions
list Sequence Container
deque Sequence Container
Associative Containers
multiset Associative Container
set Associative Container
multimap Associative Container
map Associative Container
Container Adaptors
stack Adaptor
queue Adaptor
priority_queue Adaptor
bitset Near Container
Lesson 14, Standard Library Algorithms
Lesson 14 Overview—Standard Library Algorithms
Algorithm Requirements: C++20 Concepts
Lambdas and Algorithms
Lambdas and Algorithms: Part 2
fill, fill_n, generate and generate_n
equal, mismatch and lexicographical_compare
remove, remove_if, remove_copy and remove_copy_if
replace, replace_if, replace_copy and replace_copy_if
Shuffling, Counting, and Minimum and Maximum Element Algorithms
Searching and Sorting Algorithms
swap, iter_swap and swap_ranges
copy_backward, merge, unique, reverse, copy_if and copy_n
inplace_merge, unique_copy and reverse_copy
Set Operations
lower_bound, upper_bound and equal_range
min, max and minmax
Algorithms gcd, lcm, iota, reduce and partial_sum from Header
Heapsort and Priority Queues
Function Objects (Functors)
Projections
C++20 Views and Functional-Style Programming
Range Adaptors
Working with Range Adaptors and Views
A Look Ahead to C++23 Ranges