C++20 for Programmers, 3rd Edition
- Length: 1008 pages
- Edition: 3
- Language: English
- Publisher: Pearson
- Publication Date: 2022-01-31
- ISBN-10: 0136905692
- ISBN-13: 9780136905691
- Sales Rank: #1451883 (See Top 100 Books)
The professional programmer’s Deitel® guide to Modern C++ Using C++20, the C++ Standard Library, open-source libraries and more
The C++ programming language is popular for developing systems software, embedded systems, operating systems, real-time systems, games, communications systems and other high-performance computer applications. C++20 for Programmers is an introductory-through-intermediate-level, tutorial presentation of Modern C++, which consists of the four most recent C++ standards―C++11, C++14, C++17 and C++20.
Written for programmers with a background in another high-level language, C++20 for Programmers applies the Deitel signature live-code approach to teaching Modern C++ and explores the C++20 language and libraries in depth. The book presents concepts in fully tested programs, complete with code walkthroughs, syntax coloring, code highlighting and program outputs. It features hundreds of complete C++20 programs with thousands of lines of proven code, and hundreds of software-development tips with a special focus on performance and security, that will help you build robust applications.
Start with C++ fundamentals and the Deitels’ classic treatment of object-oriented programming―classes, inheritance, polymorphism, operator overloading and exception handling. Then discover additional topics, including:
- Functional-style programming and lambdas
- Concurrency and parallelism for optimal multi-core and big data performance
- The Standard Template Library’s containers, iterators and algorithms upgraded to C++20
- Text files, CSV files, JSON serialization
- Defining custom function templates and class templates
Along the way, you’ll learn compelling new C++20 features, including modules, concepts, ranges, coroutines and Python-style text formatting. When you’re finished, you’ll have everything you need to build industrial-strength, object-oriented C++ applications.
Cover Page About This eBook Halftitle Page Title Page Copyright Page Pearson’s Commitment to Diversity, Equity, and Inclusion Dedication Page Contents Preface P.1 Modern C++ P.2 Target Audiences P.3 Live-Code Approach and Getting the Code P.4 Three Industrial-Strength Compilers P.6 “Objects-Natural” Learning Approach P.7 A Tour of the Book P.8 How to Get the Online Chapters and Appendices P.9 C++ Core Guidelines P.10 Industrial-Strength Static Code Analysis Tools P.11 Teaching Approach P.12 Developer Resources P.13 Docker P.14 Some Key C++ Documentation and Resources P.15 Getting Your Questions Answered P.16 Join the Deitel & Associates, Inc. Social Media Communities P.17 Deitel Pearson Products on O’Reilly Online Learning P.18 Live Instructor-Led Training with Paul Deitel P.19 College Textbook Version of C++20 for Programmers P.20 Acknowledgments About the Authors About Deitel® & Associates, Inc. Before You Begin Font and Naming Conventions Obtaining the Code Examples Compilers We Use in C++20 for Programmers Some Examples Do Not Compile and Run on All Three Compilers Installing Visual Studio Community Edition on Windows Installing Xcode on macOS Installing the Most Recent GNU C++ Version Installing the GNU Compiler Collection in Ubuntu Linux Running on the Windows Subsystem for Linux Docker and Docker Containers Getting Your C++ Questions Answered Online C++ Documentation A Note Regarding the {fmt} Text-Formatting Library Static Code Analysis Tools 1. Intro and Test-Driving Popular, Free C++ Compilers 1.1 Introduction 1.2 Test-Driving a C++20 Application 1.3 Moore’s Law, Multi-Core Processors and Concurrent Programming 1.4 A Brief Refresher on Object Orientation 1.5 Wrap-Up 2. Intro to C++20 Programming 2.1 Introduction 2.2 First Program in C++: Displaying a Line of Text 2.3 Modifying Our First C++ Program 2.4 Another C++ Program: Adding Integers 2.5 Arithmetic 2.6 Decision Making: Equality and Relational Operators 2.7 Objects Natural: Creating and Using Objects of Standard-Library Class string 2.8 Wrap-Up 3. Control Statements: Part 1 3.1 Introduction 3.2 Control Structures 3.3 if Single-Selection Statement 3.4 if…else Double-Selection Statement 3.5 while Iteration Statement 3.6 Counter-Controlled Iteration 3.7 Sentinel-Controlled Iteration 3.8 Nested Control Statements 3.9 Compound Assignment Operators 3.10 Increment and Decrement Operators 3.11 Fundamental Types Are Not Portable 3.12 Objects-Natural Case Study: Arbitrary-Sized Integers 3.13 C++20: Text Formatting with Function format 3.14 Wrap-Up 4. Control Statements: Part 2 4.1 Introduction 4.2 Essentials of Counter-Controlled Iteration 4.3 for Iteration Statement 4.4 Examples Using the for Statement 4.5 Application: Summing Even Integers 4.6 Application: Compound-Interest Calculations 4.7 do…while Iteration Statement 4.8 switch Multiple-Selection Statement 4.9 C++17 Selection Statements with Initializers 4.10 break and continue Statements 4.11 Logical Operators 4.12 Confusing the Equality (==) and Assignment (=) Operators 4.13 Objects-Natural Case Study: Using the miniz-cpp Library to Write and Read ZIP files 4.14 C++20 Text Formatting with Field Widths and Precisions 4.15 Wrap-Up 5. Functions and an Intro to Function Templates 5.1 Introduction 5.2 C++ Program Components 5.3 Math Library Functions 5.4 Function Definitions and Function Prototypes 5.5 Order of Evaluation of a Function’s Arguments 5.6 Function-Prototype and Argument-Coercion Notes 5.7 C++ Standard Library Headers 5.8 Case Study: Random-Number Generation 5.9 Case Study: Game of Chance; Introducing Scoped enums 5.10 Scope Rules 5.11 Inline Functions 5.12 References and Reference Parameters 5.13 Default Arguments 5.14 Unary Scope Resolution Operator 5.15 Function Overloading 5.16 Function Templates 5.17 Recursion 5.18 Example Using Recursion: Fibonacci Series 5.19 Recursion vs. Iteration 5.20 Lnfylun Lhqtomh Wjtz Qarcv: Qjwazkrplm xzz Xndmwwqhlz 5.21 Wrap-Up 6. arrays, vectors, Ranges and Functional-Style Programming 6.1 Introduction 6.2 arrays 6.3 Declaring arrays 6.4 Initializing array Elements in a Loop 6.5 Initializing an array with an Initializer List 6.6 C++11 Range-Based for and C++20 Range-Based for with Initializer 6.7 Calculating array Element Values and an Intro to constexpr 6.8 Totaling array Elements 6.9 Using a Primitive Bar Chart to Display array Data Graphically 6.10 Using array Elements as Counters 6.11 Using arrays to Summarize Survey Results 6.12 Sorting and Searching arrays 6.13 Multidimensional arrays 6.14 Intro to Functional-Style Programming 6.15 Objects-Natural Case Study: C++ Standard Library Class Template vector 6.16 Wrap-Up 7. (Downplaying) Pointers in Modern C++ 7.1 Introduction 7.2 Pointer Variable Declarations and Initialization 7.3 Pointer Operators 7.4 Pass-by-Reference with Pointers 7.5 Built-In Arrays 7.6 Using C++20 to_array to Convert a Built-In Array to a std::array 7.7 Using const with Pointers and the Data Pointed To 7.8 sizeof Operator 7.9 Pointer Expressions and Pointer Arithmetic 7.10 Objects-Natural Case Study: C++20 spans—Views of Contiguous Container Elements 7.11 A Brief Intro to Pointer-Based Strings 7.12 Looking Ahead to Other Pointer Topics 7.13 Wrap-Up 8. strings, string_views, Text Files, CSV Files and Regex 8.1 Introduction 8.2 string Assignment and Concatenation 8.3 Comparing strings 8.4 Substrings 8.5 Swapping strings 8.6 string Characteristics 8.7 Finding Substrings and Characters in a string 8.8 Replacing and Erasing Characters in a string 8.9 Inserting Characters into a string 8.10 C++11 Numeric Conversions 8.11 C++17 string_view 8.12 Files and Streams 8.13 Creating a Sequential File 8.14 Reading Data from a Sequential File 8.15 C++14 Reading and Writing Quoted Text 8.16 Updating Sequential Files 8.17 String Stream Processing 8.18 Raw String Literals 8.19 Objects-Natural Case Study: Reading and Analyzing a CSV File Containing Titanic Disaster Data 8.20 Objects-Natural Case Study: Intro to Regular Expressions 8.21 Wrap-Up 9. Custom Classes 9.1 Introduction 9.2 Test-Driving an Account Object 9.3 Account Class with a Data Member and Set and Get Member Functions 9.4 Account Class: Custom Constructors 9.5 Software Engineering with Set and Get Member Functions 9.6 Account Class with a Balance 9.7 Time Class Case Study: Separating Interface from Implementation 9.8 Compilation and Linking Process 9.9 Class Scope and Accessing Class Members 9.10 Access Functions and Utility Functions 9.11 Time Class Case Study: Constructors with Default Arguments 9.12 Destructors 9.13 When Constructors and Destructors Are Called 9.14 Time Class Case Study: A Subtle Trap —Returning a Reference or a Pointer to a private Data Member 9.15 Default Assignment Operator 9.16 const Objects and const Member Functions 9.17 Composition: Objects as Members of Classes 9.18 friend Functions and friend Classes 9.19 The this Pointer 9.20 static Class Members: Classwide Data and Member Functions 9.21 Aggregates in C++20 9.22 Objects-Natural Case Study: Serialization with JSON 9.23 Wrap-Up 10. OOP: Inheritance and Runtime Polymorphism 10.1 Introduction 10.2 Base Classes and Derived Classes 10.3 Relationship Between Base and Derived Classes 10.4 Constructors and Destructors in Derived Classes 10.5 Intro to Runtime Polymorphism: Polymorphic Video Game 10.6 Relationships Among Objects in an Inheritance Hierarchy 10.7 Virtual Functions and Virtual Destructors 10.8 Abstract Classes and Pure virtual Functions 10.9 Case Study: Payroll System Using Runtime Polymorphism 10.10 Runtime Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood“ 10.11 Non-Virtual Interface (NVI) Idiom 10.12 Program to an Interface, Not an Implementation 10.13 Runtime Polymorphism with std::variant and std::visit 10.14 Multiple Inheritance 10.15 protected Class Members: A Deeper Look 10.16 public, protected and private Inheritance 10.17 More Runtime Polymorphism Techniques; Compile-Time Polymorphism 10.18 Wrap-Up 11. Operator Overloading, Copy/Move Semantics and Smart Pointers 11.1 Introduction 11.2 Using the Overloaded Operators of Standard Library Class string 11.3 Operator Overloading Fundamentals 11.4 (Downplaying) Dynamic Memory Management with new and delete 11.5 Modern C++ Dynamic Memory Management: RAII and Smart Pointers 11.6 MyArray Case Study: Crafting a Valuable Class with Operator Overloading 11.7 C++20 Three-Way Comparison Operator (<=>) 11.8 Converting Between Types 11.9 explicit Constructors and Conversion Operators 11.10 Overloading the Function Call Operator () 11.11 Wrap-Up 12. Exceptions and a Look Forward to Contracts 12.1 Introduction 12.2 Exception-Handling Flow of Control 12.3 Exception Safety Guarantees and noexcept 12.4 Rethrowing an Exception 12.5 Stack Unwinding and Uncaught Exceptions 12.6 When to Use Exception Handling 12.7 Constructors, Destructors and Exception Handling 12.8 Processing new Failures 12.9 Standard Library Exception Hierarchy 12.10 C++’s Alternative to the finally Block: Resource Acquisition Is Initialization (RAII) 12.11 Some Libraries Support Both Exceptions and Error Codes 12.12 Logging 12.13 Looking Ahead to Contracts 12.14 Wrap-Up 13. Standard Library Containers and Iterators 13.1 Introduction 13.2 Introduction to Containers 13.3 Working with Iterators 13.4 A Brief Introduction to Algorithms 13.5 Sequence Containers 13.6 vector Sequence Container 13.7 list Sequence Container 13.8 deque Sequence Container 13.9 Associative Containers 13.10 Container Adaptors 13.11 bitset Near Container 13.12 Optional: A Brief Intro to Big O 13.13 Optional: A Brief Intro to Hash Tables 13.14 Wrap-Up 14. Standard Library Algorithms and C++20 Ranges & Views 14.1 Introduction 14.2 Algorithm Requirements: C++20 Concepts 14.3 Lambdas and Algorithms 14.4 Algorithms 14.5 Function Objects (Functors) 14.6 Projections 14.7 C++20 Views and Functional-Style Programming 14.8 Intro to Parallel Algorithms 14.9 Standard Library Algorithm Summary 14.10 A Look Ahead to C++23 Ranges 14.11 Wrap-Up 15. Templates, C++20 Concepts and Metaprogramming 15.1 Introduction 15.2 Custom Class Templates and Compile-Time Polymorphism 15.3 C++20 Function Template Enhancements 15.4 C++20 Concepts: A First Look 15.5 Type Traits 15.6 C++20 Concepts: A Deeper Look 15.7 Testing C++20 Concepts with static_assert 15.8 Creating a Custom Algorithm 15.9 Creating a Custom Container and Iterators 15.10 Default Arguments for Template Type Parameters 15.11 Variable Templates 15.12 Variadic Templates and Fold Expressions 15.13 Template Metaprogramming 15.14 Wrap-Up 16. C++20 Modules: Large-Scale Development 16.1 Introduction 16.2 Compilation and Linking Before C++20 16.3 Advantages and Goals of Modules 16.4 Example: Transitioning to Modules—Header Units 16.5 Modules Can Reduce Translation Unit Sizes and Compilation Times 16.6 Example: Creating and Using a Module 16.7 Global Module Fragment 16.8 Separating Interface from Implementation 16.9 Partitions 16.10 Additional Modules Examples 16.11 Migrating Code to Modules 16.12 Future of Modules and Modules Tooling 16.13 Wrap-Up 17. Parallel Algorithms and Concurrency: A High-Level View 17.1 Introduction 17.2 Standard Library Parallel Algorithms (C++17) 17.3 Multithreaded Programming 17.4 Launching Tasks with std::jthread 17.5 Producer–Consumer Relationship: A First Attempt 17.6 Producer–Consumer: Synchronizing Access to Shared Mutable Data 17.7 Producer–Consumer: Minimizing Waits with a Circular Buffer 17.8 Readers and Writers 17.9 Cooperatively Canceling jthreads 17.10 Launching Tasks with std::async 17.11 Thread-Safe, One-Time Initialization 17.12 A Brief Introduction to Atomics 17.13 Coordinating Threads with C++20 Latches and Barriers 17.14 C++20 Semaphores 17.15 C++23: A Look to the Future of C++ Concurrency 17.16 Wrap-Up 18. C++20 Coroutines 18.1 Introduction 18.2 Coroutine Support Libraries 18.3 Installing the concurrencpp and generator Libraries 18.4 Creating a Generator Coroutine with co_yield and the generator Library 18.5 Launching Tasks with concurrencpp 18.6 Creating a Coroutine with co_await and co_return 18.7 Low-Level Coroutines Concepts 18.8 C++23 Coroutines Enhancements 18.9 Wrap-Up A. Operator Precedence and Grouping B. Character Set Index 19. Stream I/O & C++20 Text Formatting 19.1 Introduction 19.2 Streams 19.3 Stream Output 19.4 Stream Input 19.5 Unformatted I/O Using read, write and gcount 19.6 Stream Manipulators 19.7 Stream Format States and Stream Manipulators 19.8 Stream Error States 19.9 Tying an Output Stream to an Input Stream 19.10 C++20 Text Formatting 19.11 Wrap-Up C. Number Systems C.1 Introduction C.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers C.3 Converting Octal and Hexadecimal Numbers to Binary Numbers C.4 Converting from Binary, Octal or Hexadecimal to Decimal C.5 Converting from Decimal to Binary, Octal or Hexadecimal C.6 Negative Binary Numbers: Two’s Complement Notation D. Preprocessor D.1 Introduction D.2 #include Preprocessing Directive D.3 #define Preprocessing Directive: Symbolic Constants D.4 #define Preprocessing Directive: Macros D.5 Conditional Compilation D.6 #error and #pragma Preprocessing Directives D.7 Operators # and ## D.8 Predefined Symbolic Constants D.9 Assertions Code Snippets
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.