
C++20 for Programmers: An Objects-Natural Approach, 3rd edition
BRAND: PEARSON
eBook edition. 1 year Subscription. Dành cho Cá nhân | Trường ĐH, Nhóm, Thư Viện: Gọi 0915920514 để báo giá Pearson, Vital Source eBook hoặc mua Sách In
Tổng quan sách
C++20 dành cho lập trình viên là bài thuyết trình hướng dẫn từ cơ bản đến trung cấp về lập trình máy tính trong phiên bản mới nhất (C++20) của ngôn ngữ lập trình C++, ngôn ngữ phổ biến để phát triển phần mềm hệ thống, lập trình hệ thống nhúng, vận hành. hệ thống thời gian thực, hệ thống truyền thông và các ứng dụng máy tính hiệu năng cao khác. Lý tưởng cho những ai đã từng làm việc với ít nhất một ngôn ngữ lập trình trước đây, C++20 dành cho Lập trình viên sử dụng cách tiếp cận "đối tượng ban đầu" đã được chứng minh, nhấn mạnh vào tính rõ ràng của chương trình, khả năng tái sử dụng phần mềm và xây dựng phần mềm theo định hướng thành phần. Ngoài ngôn ngữ cốt lõi, nó sẽ giúp bạn tận dụng các thư viện tiêu chuẩn mới nhất và các phần mở rộng ngôn ngữ mới nhất.
- Preface xxiBefore You Begin xliii
- Chapter 1: Intro and Test-Driving Popular, Free C++ Compilers 11.1 Introduction 21.2 Test-Driving a C++20 Application 41.3 Moore's Law, Multi-Core Processors and Concurrent Programming 161.4 A Brief Refresher on Object Orientation 171.5 Wrap-Up 20
- Chapter 2: Intro to C++20 Programming 212.1 Introduction 222.2 First Program in C++: Displaying a Line of Text 222.3 Modifying Our First C++ Program 252.4 Another C++ Program: Adding Integers 262.5 Arithmetic 302.6 Decision Making: Equality and Relational Operators 312.7 Objects Natural: Creating and Using Objects of Standard-Library Class string 352.8 Wrap-Up 38
- Chapter 3: Control Statements: Part 1 393.1 Introduction 403.2 Control Structures 403.3 if Single-Selection Statement 433.4 if…else Double-Selection Statement 443.5 while Iteration Statement 473.6 Counter-Controlled Iteration 483.7 Sentinel-Controlled Iteration 503.8 Nested Control Statements 543.9 Compound Assignment Operators 573.10 Increment and Decrement Operators 583.11 Fundamental Types Are Not Portable 603.12 Objects-Natural Case Study: Arbitrary-Sized Integers 613.13 C++20: Text Formatting with Function format 653.14 Wrap-Up 67
- Chapter 4: Control Statements: Part 2 694.1 Introduction 704.2 Essentials of Counter-Controlled Iteration 704.3 for Iteration Statement 714.4 Examples Using the for Statement 744.5 Application: Summing Even Integers 744.6 Application: Compound-Interest Calculations 754.7 do…while Iteration Statement 784.8 switch Multiple-Selection Statement 804.9 C++17 Selection Statements with Initializers 854.10 break and continue Statements 864.11 Logical Operators 884.12 Confusing the Equality (==) and Assignment (=) Operators 924.13 Objects-Natural Case Study: Using the miniz-cpp Library to Write and Read ZIP files 944.14 C++20 Text Formatting with Field Widths and Precisions 984.15 Wrap-Up 100
- Chapter 5: Functions and an Intro to Function Templates 1015.1 Introduction 1025.2 C++ Program Components 1035.3 Math Library Functions 1035.4 Function Definitions and Function Prototypes 1055.5 Order of Evaluation of a Function's Arguments 1085.6 Function-Prototype and Argument-Coercion Notes 1085.7 C++ Standard Library Headers 1115.8 Case Study: Random-Number Generation 1135.9 Case Study: Game of Chance; Introducing Scoped enums 1195.10 Scope Rules 1245.11 Inline Functions 1285.12 References and Reference Parameters 1295.13 Default Arguments 1325.14 Unary Scope Resolution Operator 1335.15 Function Overloading 1345.16 Function Templates 1375.17 Recursion 1395.18 Example Using Recursion: Fibonacci Series 1425.19 Recursion vs. Iteration 1455.20 Lnfylun Lhqtomh Wjtz Qarcv: Qjwazkrplm xzz Xndmwwqhlz 1475.21 Wrap-Up 150
- Chapter 6: arrays, vectors, Ranges and Functional-Style Programming 1536.1 Introduction 1546.2 arrays 1556.3 Declaring arrays 1556.4 Initializing array Elements in a Loop 1556.5 Initializing an array with an Initializer List 1586.6 C++11 Range-Based for and C++20 Range-Based for with Initializer 1596.7 Calculating array Element Values and an Intro to constexpr 1616.8 Totaling array Elements 1636.9 Using a Primitive Bar Chart to Display array Data Graphically 1646.10 Using array Elements as Counters 1656.11 Using arrays to Summarize Survey Results 1666.12 Sorting and Searching arrays 1686.13 Multidimensional arrays 1706.14 Intro to Functional-Style Programming 1746.15 Objects-Natural Case Study: C++ Standard Library Class Template vector 1806.16 Wrap-Up 187
- Chapter 7: (Downplaying) Pointers in Modern C++ 1897.1 Introduction 1907.2 Pointer Variable Declarations and Initialization 1927.3 Pointer Operators 1927.4 Pass-by-Reference with Pointers 1957.5 Built-In Arrays 1997.6 Using C++20 to_array to Convert a Built-In Array to a std::array 2017.7 Using const with Pointers and the Data Pointed To 2027.8 sizeof Operator 2057.9 Pointer Expressions and Pointer Arithmetic 2087.10 Objects-Natural Case Study: C++20 spans--Views of Contiguous Container Elements 2107.11 A Brief Intro to Pointer-Based Strings 2167.12 Looking Ahead to Other Pointer Topics 2207.13 Wrap-Up 220
- Chapter 8: strings, string_views, Text Files, CSV Files and Regex 2218.1 Introduction 2228.2 string Assignment and Concatenation 2238.3 Comparing strings 2258.4 Substrings 2268.5 Swapping strings 2278.6 string Characteristics 2278.7 Finding Substrings and Characters in a string 2308.8 Replacing and Erasing Characters in a string 2328.9 Inserting Characters into a string 2348.10 C++11 Numeric Conversions 2358.11 C++17 string_view 2368.12 Files and Streams 2398.13 Creating a Sequential File 2408.14 Reading Data from a Sequential File 2438.15 C++14 Reading and Writing Quoted Text 2458.16 Updating Sequential Files 2468.17 String Stream Processing 2478.18 Raw String Literals 2498.19 Objects-Natural Case Study: Reading and Analyzing a CSV File Containing Titanic Disaster Data 2508.20 Objects-Natural Case Study: Intro to Regular Expressions 2598.21 Wrap-Up 267
- Chapter 9: Custom Classes 2699.1 Introduction 2709.2 Test-Driving an Account Object 2719.3 Account Class with a Data Member and Set and Get Member Functions 2729.4 Account Class: Custom Constructors 2759.5 Software Engineering with Set and Get Member Functions 2799.6 Account Class with a Balance 2809.7 Time Class Case Study: Separating Interface from Implementation 2839.8 Compilation and Linking Process 2909.9 Class Scope and Accessing Class Members 2919.10 Access Functions and Utility Functions 2929.11 Time Class Case Study: Constructors with Default Arguments 2929.12 Destructors 2989.13 When Constructors and Destructors Are Called 2989.14 Time Class Case Study: A Subtle Trap--Returning a Reference or a Pointer to a private Data Member 3029.15 Default Assignment Operator 3049.16 const Objects and const Member Functions 3069.17 Composition: Objects as Members of Classes 3089.18 friend Functions and friend Classes 3139.19 The this Pointer 3149.20 static Class Members: Classwide Data and Member Functions 3209.21 Aggregates in C++20 3249.22 Objects-Natural Case Study: Serialization with JSON 3269.23 Wrap-Up 333
- Chapter 10: OOP: Inheritance and Runtime Polymorphism 33510.1 Introduction 33610.2 Base Classes and Derived Classes 33910.3 Relationship Between Base and Derived Classes 34110.4 Constructors and Destructors in Derived Classes 34910.5 Intro to Runtime Polymorphism: Polymorphic Video Game 35010.6 Relationships Among Objects in an Inheritance Hierarchy 35110.7 Virtual Functions and Virtual Destructors 35710.8 Abstract Classes and Pure virtual Functions 36210.9 Case Study: Payroll System Using Runtime Polymorphism 36310.10 Runtime Polymorphism, Virtual Functions and Dynamic Binding "Under the Hood" 37310.11 Non-Virtual Interface (NVI) Idiom 37610.12 Program to an Interface, Not an Implementation 38310.13 Runtime Polymorphism with std::variant and std::visit 39110.14 Multiple Inheritance 39710.15 protected Class Members: A Deeper Look 40510.16 public, protected and private Inheritance 40610.17 More Runtime Polymorphism Techniques; Compile-Time Polymorphism 40810.18 Wrap-Up 412
- Chapter 11: Operator Overloading, Copy/Move Semantics and Smart Pointers 41511.1 Introduction 41611.2 Using the Overloaded Operators of Standard Library Class string 41811.3 Operator Overloading Fundamentals 42311.4 (Downplaying) Dynamic Memory Management with new and delete 42511.5 Modern C++ Dynamic Memory Management: RAII and Smart Pointers 42711.6 MyArray Case Study: Crafting a Valuable Class with Operator Overloading 43011.7 C++20 Three-Way Comparison Operator () 45911.8 Converting Between Types 46211.9 explicit Constructors and Conversion Operators 46311.10 Overloading the Function Call Operator () 46611.11 Wrap-Up 466
- Chapter 12: Exceptions and a Look Forward to Contracts 46712.1 Introduction 46812.2 Exception-Handling Flow of Control 47112.3 Exception Safety Guarantees and noexcept 47612.4 Rethrowing an Exception 47712.5 Stack Unwinding and Uncaught Exceptions 47912.6 When to Use Exception Handling 48112.7 Constructors, Destructors and Exception Handling 48312.8 Processing new Failures 48712.9 Standard Library Exception Hierarchy 49012.10 C++'s Alternative to the finally Block: Resource Acquisition Is Initialization (RAII) 49312.11 Some Libraries Support Both Exceptions and Error Codes 49312.12 Logging 49412.13 Looking Ahead to Contracts 49512.14 Wrap-Up 503
- Chapter 13: Standard Library Containers and Iterators 50513.1 Introduction 50613.2 Introduction to Containers 50813.3 Working with Iterators 51313.4 A Brief Introduction to Algorithms 51813.5 Sequence Containers 51813.6 vector Sequence Container 51913.7 list Sequence Container 52613.8 deque Sequence Container 53113.9 Associative Containers 53313.10 Container Adaptors 54313.11 bitset Near Container 54713.12 Optional: A Brief Intro to Big O 54913.13 Optional: A Brief Intro to Hash Tables 55213.14 Wrap-Up 553
- Chapter 14: Standard Library Algorithms and C++20 Ranges & Views 55514.1 Introduction 55614.2 Algorithm Requirements: C++20 Concepts 55814.3 Lambdas and Algorithms 56014.4 Algorithms 56314.5 Function Objects (Functors) 60314.6 Projections 60814.7 C++20 Views and Functional-Style Programming 61114.8 Intro to Parallel Algorithms 61714.9 Standard Library Algorithm Summary 61914.10 A Look Ahead to C++23 Ranges 62214.11 Wrap-Up 623
- Chapter 15: Templates, C++20 Concepts and Metaprogramming 62515.1 Introduction 62615.2 Custom Class Templates and Compile-Time Polymorphism 62915.3 C++20 Function Template Enhancements 63415.4 C++20 Concepts: A First Look 63615.5 Type Traits 64415.6 C++20 Concepts: A Deeper Look 64815.7 Testing C++20 Concepts with static_assert 65915.8 Creating a Custom Algorithm 66115.9 Creating a Custom Container and Iterators 66315.10 Default Arguments for Template Type Parameters 67815.11 Variable Templates 67815.12 Variadic Templates and Fold Expressions 67915.13 Template Metaprogramming 69315.14 Wrap-Up 705
- Chapter 16: C++20 Modules: Large-Scale Development 70716.1 Introduction 70816.2 Compilation and Linking Before C++20 71016.3 Advantages and Goals of Modules 71116.4 Example: Transitioning to Modules--Header Units 71216.5 Modules Can Reduce Translation Unit Sizes and Compilation Times 71516.6 Example: Creating and Using a Module 71616.7 Global Module Fragment 72416.8 Separating Interface from Implementation 72516.9 Partitions 73216.10 Additional Modules Examples 74016.11 Migrating Code to Modules 74616.12 Future of Modules and Modules Tooling 74616.13 Wrap-Up 748
- Chapter 17: Parallel Algorithms and Concurrency: A High-Level View 75517.1 Introduction 75617.2 Standard Library Parallel Algorithms (C++17) 75917.3 Multithreaded Programming 76717.4 Launching Tasks with std::jthread 77117.5 Producer–Consumer Relationship: A First Attempt 77617.6 Producer–Consumer: Synchronizing Access to Shared Mutable Data 78317.7 Producer–Consumer: Minimizing Waits with a Circular Buffer 79517.8 Readers and Writers 80417.9 Cooperatively Canceling jthreads 80517.10 Launching Tasks with std::async 80817.11 Thread-Safe, One-Time Initialization 81517.12 A Brief Introduction to Atomics 81617.13 Coordinating Threads with C++20 Latches and Barriers 82017.14 C++20 Semaphores 82617.15 C++23: A Look to the Future of C++ Concurrency 83017.16 Wrap-Up 831
- Chapter 18: C++20 Coroutines 83318.1 Introduction 83418.2 Coroutine Support Libraries 83518.3 Installing the concurrencpp and generator Libraries 83718.4 Creating a Generator Coroutine with co_yield and the generator Library 83718.5 Launching Tasks with concurrencpp 84118.6 Creating a Coroutine with co_await and co_return 84518.7 Low-Level Coroutines Concepts 85318.8 C++23 Coroutines Enhancements 85518.9 Wrap-Up 856Appendix A: Operator Precedence and Grouping 857Appendix B: Character Set 859Index 861Online Chapters and Appendices
- Chapter 19: Stream I/O and C++20 Text Formatting
- Chapter 20: Other Topics and a Look Toward the Future of C++Appendix C: Number SystemsAppendix D: PreprocessorAppendix E: Bit Manipulation