Who Uses Programs Written in C++?
Steps to Generating an Executable
Analyzing Errors and “Debugging”
Integrated Development Environments
Programming Your First C++ Application
Building and Executing Your First C++ Application
LESSON 2: The Anatomy of a C++ Program
Parts of the Hello World Program
Preprocessor Directive #include
The Body of Your Program main()
Basic Input Using std::cin
and Output Using std::cout
LESSON 3: Using Variables, Declaring Constants
Memory and Addressing in Brief
Declaring Variables to Access and Use Memory
Declaring and Initializing Multiple Variables of a Type
Understanding the Scope of a Variable
Common Compiler-Supported C++ Variable Types
Using Type bool
to Store Boolean Values
Using Type char
to Store Character Values
The Concept of Signed and Unsigned Integers
Signed Integer Types short, int, long
, and long long
Unsigned Integer Types unsigned short, unsigned int, unsigned long
, and unsigned long long
Avoid Overflow Errors by Selecting Correct Data Types
Floating-Point Types float
and double
Determining the Size of a Variable Using sizeof
Avoid Narrowing Conversion Errors by Using List Initialization
Automatic Type Inference Using auto
Using typedef
to Substitute a Variable’s Type
Declaring Variables as Constants Using const
Constant Expressions Using constexpr
Defining Constants Using #define
Keywords You Cannot Use as Variable or Constant Names
LESSON 4: Managing Arrays and Strings
Declaring and Initializing Static Arrays
How Data Is Stored in an Array
Accessing Data Stored in an Array
Modifying Data Stored in an Array
Declaring and Initializing Multidimensional Arrays
Accessing Elements in a Multidimensional Array
C++ Strings: Using std::string
LESSON 5: Working with Expressions, Statements, and Operators
Understanding L-values and R-values
Operators to Add (+
), Subtract (-
), Multiply (*
), Divide (/
), and Modulo Divide (%
)
Operators to Increment (++
) and Decrement (--
)
Equality Operators (==
) and (!=
)
Logical Operations NOT, AND, OR, and XOR
Using C++ Logical Operators NOT (!
), AND (&&
), and OR (||
)
Bitwise NOT (~
), AND (&
), OR (|
), and XOR (^
) Operators
Bitwise Right Shift (>>
) and Left Shift (<<
) Operators
Using Operator sizeof
to Determine the Memory Occupied by a Variable
LESSON 6: Controlling Program Flow
Conditional Execution Using if ... else
Conditional Programming Using if ... else
Executing Multiple Statements Conditionally
Conditional Processing Using switch-case
Conditional Execution Using Operator (?:
)
Getting Code to Execute in Loops
Modifying Loop Behavior Using continue
and break
Loops That Don’t End—That Is, Infinite Loops
Using Nested Loops to Walk a Multidimensional Array
Using Nested Loops to Calculate Fibonacci Numbers
LESSON 7: Organizing Code with Functions
What Is a Function Definition?
What Is a Function Call, and What Are Arguments?
Programming a Function with Multiple Parameters
Programming Functions with No Parameters or No Return Values
Function Parameters with Default Values
Recursion—Functions That Invoke Themselves
Functions with Multiple Return Statements
Using Functions to Work with Different Forms of Data
Passing an Array of Values to a Function
Passing Arguments by Reference
How Function Calls Are Handled by the Microprocessor
Automatic Return Type Deduction
LESSON 8: Pointers and References Explained
Determining the Address of a Variable Using the Reference Operator (&
)
Using Pointers to Store Addresses
Access Pointed Data Using the Dereference Operator (*
)
What Is the sizeof()
of a Pointer?
Using Operators new
and delete
to Allocate and Release Memory Dynamically
Effect of Incrementing and Decrementing Operators (++
and --
) on Pointers
Using the const
Keyword on Pointers
Similarities between Arrays and Pointers
Common Programming Mistakes When Using Pointers
When Pointers Don’t Point to Valid Memory Locations
Dangling Pointers (Also Called Stray or Wild Pointers)
Checking Whether Allocation Request Using new
Succeeded
Pointer Programming Best-Practices
Using Keyword const
on References
Passing Arguments by Reference to Functions
PART II: Fundamentals of Object-Oriented C++ Programming
The Concept of Classes and Objects
An Object as an Instance of a Class
Accessing Members Using the Dot Operator (.
)
Accessing Members Using the Pointer Operator (->
)
Abstraction of Data via Keyword private
Declaring and Implementing a Constructor
When and How to Use Constructors
Class Without a Default Constructor
Constructor Parameters with Default Values
Constructors with Initialization Lists
Declaring and Implementing a Destructor
When and How to Use a Destructor
Shallow Copying and Associated Problems
Ensuring Deep Copy Using a Copy Constructor
Move Constructors Help Improve Performance
Different Uses of Constructors and the Destructor
Class That Does Not Permit Copying
Singleton Class That Permits a Single Instance
Class That Prohibits Instantiation on the Stack
Using Constructors to Convert Types
union
: A Special Data Storage Mechanism
Using Aggregate Initialization on Classes and Structs
constexpr
with Classes and Objects
LESSON 10: Implementing Inheritance
Access Specifier Keyword protected
Base Class Initialization—Passing Parameters to the Base Class
Derived Class Overriding Base Class’s Methods
Invoking Overridden Methods of a Base Class
Invoking Methods of a Base Class in a Derived Class
Derived Class Hiding Base Class’s Methods
Avoiding Inheritance Using final
Polymorphic Behavior Implemented Using Virtual Functions
How Do virtual
Functions Work? Understanding the Virtual Function Table
Abstract Base Classes and Pure Virtual Functions
Using virtual
Inheritance to Solve the Diamond Problem
Specifier Override
to Indicate Intention to Override
Use final
to Prevent Function Overriding
LESSON 12: Operator Types and Operator Overloading
Programming a Unary Increment/Decrement Operator
Programming Conversion Operators
Programming Dereference Operator (*
) and Member Selection Operator (->
)
Programming Binary Addition (a+b
) and Subtraction (a-b
) Operators
Implementing Addition Assignment (+=
) and Subtraction Assignment (-=
) Operators
Overloading Equality (==
) and Inequality (!=
) Operators
Overloading <
, >
, <=
, and >=
Operators
Overloading Copy Assignment Operator (=
)
Move Constructor and Move Assignment Operator for High Performance Programming
The Problem of Unwanted Copy Steps
Declaring a Move Constructor and Move Assignment Operator
Operators That Cannot Be Overloaded
Why C-Style Casts Are Not Popular with Some C++ Programmers
Using dynamic_cast
and Runtime Type Identification
Problems with the C++ Casting Operators
LESSON 14: An Introduction to Macros and Templates
The Preprocessor and the Compiler
Using Macro #define
to Define Constants
Using Macros for Protection against Multiple Inclusion
Using #define
to Write Macro Functions
Using Macro assert
to Validate Expressions
Advantages and Disadvantages of Using Macro Functions
The Different Types of Template Declarations
Declaring Templates with Multiple Parameters
Declaring Templates with Default Parameters
Sample Template class<> HoldsPair
Template Instantiation and Specialization
Template Classes and static
Members
Variable Templates, Also Called Variadic Templates
Using static_assert
to Perform Compile-Time Checks
Using Templates in Practical C++ Programming
PART III: Learning the Standard Template Library (STL)
LESSON 15: An Introduction to the Standard Template Library
The Interaction between Containers and Algorithms Using Iterators
Using Keyword auto
to Let Compiler Define Type
LESSON 16: The STL String Class
The Need for String Manipulation Classes
Working with the STL String Class
Instantiating the STL String and Making Copies
Accessing Character Contents of a std::string
Concatenating One String to Another
Finding a Character or Substring in a String
Template-Based Implementation of an STL String
C++14 operator “”s
in std::string
LESSON 17: STL Dynamic Array Classes
The Characteristics of std::vector
Inserting Elements at the End Using push_back()
Inserting Elements at a Given Position Using insert()
Accessing Elements in a Vector Using Array Semantics
Accessing Elements in a Vector Using Pointer Semantics
Removing Elements from a Vector
Understanding the Concepts of Size and Capacity
LESSON 18: STL list
and forward_list
The Characteristics of a std::list
Instantiating a std::list
Object
Inserting Elements at the Front or Back of the List
Inserting at the Middle of the List
Erasing Elements from the List
Reversing and Sorting Elements in a List
Reversing Elements Using list::reverse()
Sorting and Removing Elements from a list
That Contains Instances of a class
std::forward_list
Introduced in C++11
An Introduction to STL Set Classes
Basic STL set
and multiset
Operations
Instantiating a std::set
Object
Inserting Elements in a set
or multiset
Finding Elements in an STL set
or multiset
Erasing Elements in an STL set
or multiset
Pros and Cons of Using STL set
and multiset
STL Hash Set Implementation std::unordered_set
and std::unordered_multiset
An Introduction to STL Map Classes
Basic std::map
and std::multimap
Operations
Instantiating a std::map
or std::multimap
Inserting Elements in an STL map
or multimap
Finding Elements in an STL map
Finding Elements in an STL multimap
Erasing Elements from an STL map
or multimap
Supplying a Custom Sort Predicate
STL’s Hash Table-Based Key-Value Container
Using unordered_map
and unordered_multimap
LESSON 21: Understanding Function Objects
The Concept of Function Objects and Predicates
Typical Applications of Function Objects
How to Define a Lambda Expression
Lambda Expression for a Unary Function
Lambda Expression for a Unary Predicate
Lambda Expression with State via Capture Lists [...]
The Generic Syntax of Lambda Expressions
Lambda Expression for a Binary Function
Lambda Expression for a Binary Predicate
Classification of STL Algorithms
Finding Elements Given a Value or a Condition
Counting Elements Given a Value or a Condition
Searching for an Element or a Range in a Collection
Initializing Elements in a Container to a Specific Value
Using std::generate()
to Initialize Elements to a Value Generated at Runtime
Processing Elements in a Range Using for_each()
Performing Transformations on a Range Using std::transform()
Replacing Values and Replacing Element Given a Condition
Sorting and Searching in a Sorted Collection and Erasing Duplicates
Inserting Elements in a Sorted Collection
LESSON 24: Adaptive Containers: Stack and Queue
The Behavioral Characteristics of Stacks and Queues
Insertion and Removal at Top Using push()
and pop()
Insertion at End and Removal at the Beginning of queue
via push()
and pop()
Instantiating the priority_queue
Class
Member Functions of priority_queue
Insertion at the End and Removal at the Beginning of priority_queue
via push()
and pop()
LESSON 25: Working with Bit Flags Using STL
Using std::bitset
and Its Members
Useful Operators Featured in std::bitset
vector<bool>
Functions and Operators
LESSON 26: Understanding Smart Pointers
The Problem with Using Conventional (Raw) Pointers
How Are Smart Pointers Implemented?
Reference-Counted Smart Pointers
Reference-Linked Smart Pointers
Popular Smart Pointer Libraries
LESSON 27: Using Streams for Input and Output
Important C++ Stream Classes and Objects
Using std::cout
for Writing Formatted Data to Console
Changing Display Number Formats Using std::cout
Aligning Text and Setting Field Width Using std::cout
Using std::cin
for Input into a Plain Old Data Type
Using std::cin::get
for Input into char*
Buffer
Using std::cin
for Input into a std::string
Using std::fstream
for File Handling
Opening and Closing a File Using open()
and close()
Creating and Writing a Text File Using open()
and operator<<
Reading a Text File Using open()
and operator>>
Writing to and Reading from a Binary File
Using std::stringstream
for String Conversions
Implementing Exception Safety via try
and catch
Using catch(...)
to Handle All Exceptions
Throwing Exception of a Type Using throw
Your Custom Exception Class Derived from std::exception
What’s Different in Today’s Processors?
How to Better Use Multiple Cores
Why Program Multithreaded Applications?
How Can Threads Transact Data?
Using Mutexes and Semaphores to Synchronize Threads
Problems Caused by Multithreading
if
and switch
Support Initializers
std::string_view
Avoids Allocation Overheads
std::variant
As a Typesafe Alternative to a union
Conditional Code Compilation Using if constexpr
Automatic Type Deduction for Constructors
Learning C++ Doesn’t Stop Here!
Communities for Guidance and Help
APPENDIX A: Working with Numbers: Binary and Hexadecimal
18.189.182.96