Author(s): John Paul Mueller
Edition: 4
Publisher: For dummies
Year: 2021 January 7
Language: English
Pages: 915
Title Page
Copyright Page
Table of Contents
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Book 1 Getting Started with C++
Chapter 1 Configuring Your Desktop System
Obtaining a Copy of C++ 20
Obtaining Code::Blocks
Installing Code::Blocks
Working with Windows
Working with Mac OS X
Using the standard Linux installation
Using the graphical Linux installation
Touring the Essential Code::Blocks Features
Starting Code::Blocks for the first time
Opening the sample projects
Viewing the essential windows
Using Other IDEs
Chapter 2 Configuring Your Mobile System
Obtaining CppDroid
Understanding why CppDroid is such a great choice
Getting your copy of CppDroid
Ensuring you get a good install
Considering Other Alternatives
Working with C4Droid
Getting multiple language support with AIDE
Using web-based IDEs
Touring the Essential CppDroid Features
Getting started with CppDroid
Accessing an example
Working with a simple online project
Accessing your source code
Considering differences with the desktop environment
Obtaining CppDroid Help
Working with the Help documentation
Getting community support
Using the free examples
Accessing the tutorials
Chapter 3 Creating Your First C++ Application
Code::Blocks Creating a Project
Understanding projects
Defining your first project
Building and executing your first application
Typing the Code
Starting with Main
Showing Information
Doing some math
Tabbing your output
Let Your Application Run Away
Chapter 4 Storing Data in C++
Putting Your Data Places: Variables
Creating an integer variable
Declaring multiple variables
Changing values
Setting one variable equal to another
Initializing a variable
Creating a great name for yourself
Manipulating Integer Variables
Adding integer variables
Subtracting integer variables
Multiplying integer variables
Dividing integer variables
Characters
Null character
Nonprintable and other cool characters
Strings
Getting a part of a string
Changing part of a string
Adding onto a string
Adding two strings
Making Decisions Using Conditional Operators
Telling the Truth with Boolean Variables
Reading from the Console
Chapter 5 Directing the Application Flow
Doing This or Doing That
Evaluating Conditions in C++
Finding the right C++ operators
Combining multiple evaluations
Including Evaluations in C++ Conditional Statements
Deciding what if and also what else
Going further with the else and if
Repeating Actions with Statements That Loop
Understanding how computers use loops
Looping situations
Looping for
Performing a simple for loop
Using multiple initialization variables
Working with ranges
Placing a condition within the declaration
Letting C++ determine the type
Looping while
Doing while
Breaking and continuing
Breaking
Continuing
Nesting loops
Chapter 6 Dividing Your Work with Functions
Dividing Your Work
Calling a Function
Passing a variable
Passing multiple variables
Writing Your Own Functions
Defining the AddOne() function
Seeing how AddOne() is called
Taking the AddOne() Function apart
Considering the AddOne() parameter
Understanding the AddOne() name and type
Improving On the Basic Function
Using multiple parameters or no parameters
Returning nothing
Keeping your variables local
Forward references and function prototypes
Writing two versions of the same function
Calling All String Functions
Inserting a string into a string
Removing parts of a string
Replacing parts of a string
Using the string functions together
Understanding main()
Chapter 7 Splitting Up Source Code Files
Creating Multiple Source Files
Adding a new source code file
Removing an existing source code file
Creating a project with multiple existing files
Getting multiple files to interact
Sharing with Header Files
Adding the header only once
Using angle brackets or quotes
Sharing Variables among Source Files
Using the Mysterious Header Wrappers
Chapter 8 Referring to Your Data Through Pointers
Understanding the Changes in Pointers for C++ 20
Avoiding broken code
Considering the issues
Writing cleaner and less bug-prone code
Heaping and Stacking the Variables
Getting a variable’s address
Changing a variable by using a pointer
Pointing at a string
Pointing to something else
Tips on pointer variables
Creating New Raw Pointers
Using new
Using an initializer
Freeing Raw Pointers
Working with Smart Pointers
Creating smart pointers using std::unique_ptr and std::shared_ptr
Defining nullable values using std::optional and std::nullopt
Passing Pointer Variables to Functions
Returning Pointer Variables from Functions
Book 2 Understanding Objects and Classes
Chapter 1 Working with Classes
Understanding Objects and Classes
Classifying classes and objects
Describing methods and data
Implementing a class
Separating method code
The parts of a class
Working with a Class
Accessing members
Using classes and raw pointers
Using classes and smart pointers
Passing objects to functions
Using const parameters in functions
Using the this pointer
Overloading methods
Starting and Ending with Constructors and Destructors
Starting with constructors
Ending with destructors
Sampling constructors and destructors
Adding parameters to constructors
Building Hierarchies of Classes
Creating a hierarchy in C++
Understanding types of inheritance
Creating and Using Object Aliases
Chapter 2 Using Advanced C++ Features
Filling Your Code with Comments
Converting Types
Understanding how int and string conversions work
Seeing int and string conversions in action
Considering other conversion issues
Reading from the Console
Understanding Preprocessor Directives
Understanding the basics of preprocessing
Creating constants and macros with #define
Performing conditional compilation
Exercising the basic preprocessor directives
Using Constants
Using Switch Statements
Supercharging enums with Classes
Working with Random Numbers
Storing Data in Arrays
Declaring and accessing an array
Arrays of pointers
Passing arrays to functions
Adding and subtracting pointers
Chapter 3 Planning and Building Objects
Recognizing Objects
Observing the Mailboxes class
Observing the Mailbox class
Finding other objects
Encapsulating Objects
Considering the Application Programming Interface
Understanding properties
Choosing between private and protected
Defining a process
Implementing properties
Building Hierarchies
Establishing a hierarchy
Protecting members when inheriting
Overriding methods
Specializing with polymorphism
Getting abstract about things
Chapter 4 Building with Design Patterns
Delving Into Pattern History
Introducing a Simple Pattern: the Singleton
Using an existing pattern
Creating a singleton pattern class
Watching an Instance with an Observer
Understanding the observer pattern
Defining an observer pattern class
Observers and the Standard C++ Library
Automatically adding an observer
Mediating with a Pattern
Defining the mediator pattern scenario
Outlining the car example
Creating the car example
Book 3 Understanding Functional Programming
Chapter 1 Considering Functional Programming
Understanding How Functional Programming Differs
Defining an Impure Language
Considering the requirements
Understanding the C++ functional limitations
Seeing Data as Immutable
Working with immutable variables
Working with immutability in classes and structures
Creating constant expressions
Considering the Effects of State
Eliminating Side Effects
Contrasting declarations and functions
Associating functions with side effects
Removing side effects
Creating a declarative C++ example
Understanding the Role of auto
Passing Functions to Functions
Seeing a simple example of function input
Using transforms
Using Lambda Expressions for Implementation
Chapter 2 Working with Lambda Expressions
Creating More Readable and Concise C++ Code
Defining the Essential Lambda Expression
Defining the parts of a lambda expression
Relying on computer detection of return type
Using the auto keyword with lambda expressions
Using lambda expressions as macros
Developing with Lambda Expressions
Using lambda expressions with classes and structures
Working with the capture clause
Sorting data using a lambda expression
Specifying that the lambda expression throws exceptions
Chapter 3 Advanced Lambda Expressions
Considering the C++ 20 Lambda Extensions
Defining an immediate function
Using = and this in captures
Finding other changes
Working in Unevaluated Contexts
Using Assignable Stateless Lambda Expressions
Dealing with Pack Expansions
Considering the template
Processing the variables using recursion
Processing the variables using a lambda expression
Book 4 Fixing Problems
Chapter 1 Dealing with Bugs
It’s Not a Bug. It’s a Feature!
Make Your Application Features Look Like Features
Anticipating (Almost) Everything
Considering menus
Dealing with textual input
Performing string processing
Avoiding Mistakes, Plain and Simple
Chapter 2 Debugging an Application
Programming with Debuggers
Running the debugger
Recognizing the parts of the Code::Blocks debugger
Debugging with Different Tools
Debugging a Code::Blocks Application with Command-Line Arguments
Chapter 3 Stopping and Inspecting Your Code
Setting and Disabling Breakpoints
Setting a breakpoint in Code::Blocks
Enabling and disabling breakpoints
Watching, Inspecting, and Changing Variables
Watching the variables
Changing values
Chapter 4 Traveling About the Stack
Stacking Your Data
Moving about the stack
Storing local variables
Debugging with Advanced Features
Viewing threads
Tracing through assembly code
Book 5 Advanced Programming
Chapter 1 Working with Arrays, Pointers, and References
Building Up Arrays
Declaring arrays
Arrays and pointers
Using multidimensional arrays
Arrays and command-line parameters
Allocating an array on the heap
Deleting an array from the heap
Storing arrays of pointers and arrays of arrays
Building constant arrays
Pointing with Pointers
Becoming horribly complex
Pointers to functions
Pointing a variable to a method
Pointing to static methods
Referring to References
Reference variables
Returning a reference from a function
Chapter 2 Creating Data Structures
Working with Data
The great variable roundup
Expressing variables from either side
Casting a spell on your data
Comparing casting and converting
Casting safely with C++
Structuring Your Data
Structures as component data types
Equating structures
Returning compound data types
Naming Your Space
Creating a namespace
Employing using namespace
Using variables
Using part of a namespace
Chapter 3 Constructors, Destructors, and Exceptions
Constructing and Destructing Objects
Overloading constructors
Initializing members
Adding a default constructor
Functional constructors
Calling one constructor from another
Copying instances with copy constructors
When constructors go bad
Destroying your instances
Virtually inheriting destructors
Programming the Exceptions to the Rule
Creating a basic try. . .catch block
Using multiple catch blocks
Throwing direct instances
Catching any exception
Rethrowing an exception
Using a standard category
Chapter 4 Advanced Class Usage
Inherently Inheriting Correctly
Morphing your inheritance
Avoiding polymorphism
Adjusting access
Avoiding variable naming conflicts
Using class-based access adjustment
Returning something different, virtually speaking
Multiple inheritance
Virtual inheritance
Friend classes and functions
Using Classes and Types within Classes
Nesting a class
Types within classes
Chapter 5 Creating Classes with Templates
Templatizing a Class
Considering types
Defining the need for templates
Creating and using a template
Understanding the template keyword
Going Beyond the Basics
Separating a template from the function code
Including static members in a template
Parameterizing a Template
Putting different types in the parameter
Including multiple parameters
Working with non-type parameters
Typedefing a Template
Deriving Templates
Deriving classes from a class template
Deriving a class template from a class
Deriving a class template from a class template
Templatizing a Function
Overloading and function templates
Templatizing a method
Chapter 6 Programming with the Standard Library
Architecting the Standard Library
Containing Your Classes
Storing in a vector
Working with std::array
Mapping your data
Containing instances, pointers, or references
Working with copies
Comparing instances
Iterating through a container
A map of pairs in your hand
The Great Container Showdown
Associating and storing with a set
Unionizing and intersecting sets
Listing with list
Stacking the deque
Waiting in line with stacks and queues
Copying Containers
Creating and Using Dynamic Arrays
Working with Unordered Data
Using std::unordered_set to create an unordered set
Manipulating unordered sets
Working with Ranges
Book 6 Reading and Writing Files
Chapter 1 Filing Information with the Streams Library
Seeing a Need for Streams
Programming with the Streams Library
Getting the right header file
Opening a file
Reading from a file
Reading and writing a file
Working with containers
Handling Errors When Opening a File
Flagging the ios Flags
Chapter 2 Writing with Output Streams
Inserting with the << Operator
Formatting Your Output
Formatting with flags
Specifying a precision
Setting the width and creating fields
Chapter 3 Reading with Input Streams
Extracting with Operators
Encountering the End of File
Using the record count approach
Using the EOF check approach
Reading Various Types
Understanding data reading issues
Writing and reading string-type data
Writing and reading structured data
Chapter 4 Building Directories and Contents
Manipulating Directories
Creating a directory
Deleting a directory
Getting the Contents of a Directory
Copying Files
Copying with windows
Using the quick-and-dirty method
Moving and Renaming Files and Directories
Chapter 5 Streaming Your Own Classes
Streaming a Class for Text Formatting
Understanding the process
Considering the insertion implementation
Considering the extraction implementation
Manipulating a Stream
What’s a manipulator?
Writing your own manipulator
Book 7 Advanced Standard Library Usage
Chapter 1 Exploring the Standard Library Further
Considering the Standard Library Categories
Algorithms
Atomic operations
C Compatibility
Concepts
Containers
Coroutines
Filesystem
Input/Output
Iterators
Localization
Numerics
Ranges
Regular Expressions
Strings
Thread Support
Utilities
Parsing Strings Using a Hash
Obtaining Information Using a Random Access Iterator
Locating Values Using the Find Algorithm
Using the Random Number Generator
Working with Temporary Buffers
Chapter 2 Working with User-Defined Literals (UDLs)
Understanding the Need for UDLs
Prefixes and suffixes
Differentiating between raw and cooked
Working with the UDLs in the Standard Library
std::basic_string
std::complex
std::chrono::duration
Creating Your Own UDLs
Developing a conversion UDL
Developing a custom type UDL
Using a custom UDL for side effects
Chapter 3 Building Original Templates
Deciding When to Create a Template
Defining the Elements of a Good Template
Creating a Basic Math Template
Building a Structure Template
Developing a Class Template
Considering Template Specialization
Creating a Template Library
Defining the library project
Configuring the library project
Coding the library
Using Your Template Library
Chapter 4 Investigating Boost
Considering the Standard Library Alternative
Understanding why the Standard Library contains Boost features
Defining the trade-offs of using the Standard Library
Understanding Boost
Boost features
Licensing
Paid support
Obtaining and Installing Boost for Code::Blocks
Unpacking Boost
Using the header-only libraries
Building the libraries
Testing the installation
Creating the Boost Tools
Using Boost.Build
Getting a successful build
Creating your own example
Using Inspect
Understanding BoostBook
Using QuickBook
Using bcp
Using Wave
Building Your First Boost Application Using Date Time
Chapter 5 Boosting up a Step
Parsing Strings Using RegEx
Adding the RegEx library
Creating the RegEx code
Breaking Strings into Tokens Using Tokenizer
Performing Numeric Conversion
Creating Improved Loops Using Foreach
Accessing the Operating System Using Filesystem
Index
EULA