Learn the C++ programming language in a structured, straightforward, and friendly manner. This book teaches the basics of the modern C++ programming language, the C++ Standard Library, and modern C++ standards, including C++23. No previous programming experience is required.
C++ is a language like no other, surprising in its complexity, yet wonderfully sleek and elegant in so many ways. It is also a language that cannot be learned by guessing, one that is easy to get wrong and challenging to get right. To overcome this, each section is filled with real-world examples that gradually increase in complexity. Modern C++ for Absolute Beginners, Second Edition teaches more than just programming in C++23. It provides a solid C++ foundation to build upon.
The author takes you through the C++ programming language, the Standard Library, and C++11 to C++23 standard basics. Each chapter is accompanied by the right amount of theory and plenty of source code examples. You will work with C++23 features and standards, yet you will also compare and take a look into previous versions of C++.
After reading this book, you'll be able to start programming in modern C++ standards. You will do so with plenty of relevant source code examples, freely available via a dedicated GitHub repository.
What You Will Learn- Get Introduced to modern C++ in a friendly but effective way
- Work with the basics of C++: types, operators, variables, constants, expressions, references, functions, classes, I/O, smart pointers, polymorphism, and more
- Set up the Visual Studio environment on Windows and GCC on Linux, where you can write your own code
- Declare and define functions, classes, and objects, and organize code into namespaces
- Discover object-oriented programming: classes and objects, encapsulation, inheritance, polymorphism, and more using the most advanced C++ features
- Employ best practices in organizing source code and controlling program workflow
- Get familiar with C++ language do's and don'ts, and more
- Manage the basics of lambdas, inheritance, polymorphism, smart pointers, templates, modules, contracts, concepts, and more
Who This Book Is For
Beginner or novice programmers who wish to learn C++ programming. No prior programming experience is required.
Author(s): Slobodan Dmitrović
Edition: 2
Publisher: Apress
Year: 2023
Language: English
Commentary: NOTE: This ebook has bookmarks but its TOC is broken. On the other hand, B5E2615912159E9979033F9E468E7D79 doesn't have bookmarks but it's TOC is usable.
Pages: 461
City: Berkeley, CA
Tags: C++; C++11; C++14; C++17; C++20; C++23; C++ Programming Language; Modern C++; Object-Oriented Programming
Table of Contents
About the Author
About the Technical Reviewer
Acknowledgments
About the Second Edition
Chapter 1: Introduction
Chapter 2: What Is C++?
C++ Standards
Chapter 3: C++ Compilers
Installing C++ Compilers
On Linux
On Windows
Chapter 4: Our First Program
Comments
Hello World Example
Chapter 5: Types
Fundamental Types
Boolean
Character Type
Integer Types
Floating-Point Types
Type void
Type Modifiers
Variable Declaration, Definition, and Initialization
Chapter 6: Exercises
Hello World and Comments
Declaration
Definition
Initialization
Chapter 7: Operators
Assignment Operator
Arithmetic Operators
Compound Assignment Operators
Increment/Decrement Operators
Chapter 8: Standard Input
Chapter 9: Exercises
Standard Input
Two Inputs
Multiple Inputs
Inputs and Arithmetic Operations
Postincrement and Compound Assignment
Integral and Floating-Point Division
Chapter 10: Arrays
Chapter 11: Pointers
Chapter 12: References
Chapter 13: Introduction to Strings
Defining a String
Concatenating Strings
Accessing Characters
Comparing Strings
String Input
A Pointer to a String
Substrings
Finding a Substring
Chapter 14: Automatic Type Deduction
Chapter 15: Exercises
Array Definition
Pointer to an Object
Reference Type
Strings
Strings from Standard Input
Creating a Substring
Finding a Single Character
Finding a Substring
Automatic Type Deduction
Chapter 16: Statements
Selection Statements
if Statement
Conditional Expression
The Logical Operators
Comparison Operators
switch Statement
Iteration Statements
for Statement
while Statement
do Statement
Chapter 17: Constants
Chapter 18: Exercises
A Simple if Statement
Logical Operators
The switch Statement
The for Loop
Array and the for Loop
The const Type Qualifier
Chapter 19: Functions
Introduction
Function Declaration
Function Definition
Return Statement
Passing Arguments
Passing by Value/Copy
Passing by Reference
Passing by Const Reference
Function Overloading
Chapter 20: Exercises
Function Definition
Separate Declaration and Definition
Function Parameters
Passing Arguments
Function Overloads
Chapter 21: Scope and Lifetime
Local Scope
Block Scope
Lifetime
Automatic Storage Duration
Dynamic Storage Duration
Static Storage Duration
Operators new and delete
Chapter 22: Exercises
Automatic Storage Duration
Dynamic Storage Duration
Automatic and Dynamic Storage Durations
Chapter 23: Classes – Introduction
Data Member Fields
Member Functions
Access Specifiers
Constructors
Default Constructor
Member Initialization
Copy Constructor
Copy Assignment
Move Constructor
Move Assignment
Operator Overloading
Destructors
Chapter 24: Exercises
Class Instance
Class with Data Members
Class with Member Function
Class with Data and Function Members
Class Access Specifiers
User-Defined Default Constructor and Destructor
Constructor Initializer List
User-Defined Copy Constructor
User-Defined Move Constructor
Overloading Arithmetic Operators
Chapter 25: Classes – Inheritance and Polymorphism
Inheritance
Polymorphism
Chapter 26: Exercises
Inheritance
Chapter 27: The static Specifier
Chapter 28: Templates
Function Templates
Class Templates
Template Specialization
Chapter 29: Enumerations
Chapter 30: Exercises
Static Variable
Static Data Member
Static Member Function
Function Template
Class Template
Scoped Enums
Enums in a switch
Chapter 31: Organizing Code
Header and Source Files
Header Guards
Namespaces
Chapter 32: Exercises
Header and Source Files
Multiple Source Files
Namespaces
Nested Namespaces
Chapter 33: Conversions
Implicit Conversions
Explicit Conversions
Chapter 34: Exceptions
Chapter 35: Smart Pointers
Unique Pointer
Shared Pointer
Chapter 36: Exercises
static_cast Conversion
A Simple Unique Pointer
Unique Pointer to an Object of a Class
Shared Pointer Exercise
Simple Polymorphism
Polymorphism II
Exception Handling
Multiple Exceptions
Chapter 37: Input/Output Streams
File Streams
String Streams
Chapter 38: C++ Standard Library and Friends
Containers
std::vector
std::array
std::set
std::map
std::pair
Other Containers
The Range-Based for Loop
Iterators
Algorithms and Utilities
std::sort
std::find
std::copy
Min and Max Elements
Lambda Expressions
Chapter 39: Exercises
Basic Vector
Deleting a Single Value
Deleting a Range of Elements
Finding Elements in a Vector
Basic Set
Set Data Manipulation
Set Member Functions
Search for Data in a Set
Basic Map
Inserting into a Map
Searching and Deleting from a Map
Lambda Expressions
Chapter 40: C++ Standards
C++11
Automatic Type Deduction
Range-Based Loops
Initializer Lists
Move Semantics
Lambda Expressions
The constexpr Specifier
Scoped Enumerators
Smart Pointers
std::unordered_set
std::unordered_map
std::tuple
static_assert
Introduction to Concurrency
Deleted and Defaulted Functions
Type Aliases
C++14
Binary Literals
Digit Separators
Auto for Functions
Generic Lambdas
std::make_unique
C++17
Nested Namespaces
Constexpr Lambdas
Structured Bindings
std::filesystem
std::string_view
std::any
std::variant
C++20
Modules
Concepts
Lambda Templates
[likely] and [unlikely] Attributes
Ranges
Coroutines
std::span
Mathematical Constants
C++23
Multidimensional Subscript Operator
Literal Suffixes for size_t
The #warning Preprocessor Directive
The std::string::contains() Member Function
std::print
Chapter 41: Projects
Project I: Book Inventory
Project II: Book Inventory – Multiple Files
Project III: Message Logger
Project IV: Message Logger – Multiple Files
Project V: Information System
Project VI: Information System – Multiple Files
Index