دسترسی نامحدود
برای کاربرانی که ثبت نام کرده اند
برای ارتباط با ما می توانید از طریق شماره موبایل زیر از طریق تماس و پیامک با ما در ارتباط باشید
در صورت عدم پاسخ گویی از طریق پیامک با پشتیبان در ارتباط باشید
برای کاربرانی که ثبت نام کرده اند
درصورت عدم همخوانی توضیحات با کتاب
از ساعت 7 صبح تا 10 شب
ویرایش: 6
نویسندگان: Marc Gregoire
سری: Tech Today
ISBN (شابک) : 1394193173, 9781394193189
ناشر: Wiley
سال نشر: 2024
تعداد صفحات: 0
زبان: English
فرمت فایل : EPUB (درصورت درخواست کاربر به PDF، EPUB یا AZW3 تبدیل می شود)
حجم فایل: 8 مگابایت
در صورت تبدیل فایل کتاب Professional C++ به فرمت های PDF، EPUB، AZW3، MOBI و یا DJVU می توانید به پشتیبان اطلاع دهید تا فایل مورد نظر را تبدیل نمایند.
توجه داشته باشید کتاب حرفه ای سی نسخه زبان اصلی می باشد و کتاب ترجمه شده به فارسی نمی باشد. وبسایت اینترنشنال لایبرری ارائه دهنده کتاب های زبان اصلی می باشد و هیچ گونه کتاب ترجمه شده یا نوشته شده به فارسی را ارائه نمی دهد.
Cover Title Page Copyright Page About the Author Contents Introduction Who This Book Is For What This Book Covers How This Book is Structured Conventions What You Need to Use This Book Any C++ Compiler Example: Microsoft Visual C++ 2022 Example: GCC C++23’s Support for Printing Ranges Reader Support for This Book Companion Download Files How to Contact the Publisher How to Contact the Author Part I Introduction to Professional C++ Chapter 1 A Crash Course in C++ and the Standard Library C++ Crash Course The Obligatory “Hello, World” Program Comments Importing Modules How the Compiler Processes Your Source Code Preprocessor Directives The main() Function Printing Text I/O Streams Returning from a Function Namespaces Nested Namespace Namespace Alias Literals Variables Numerical Limits Zero Initialization Casting Floating-Point Numbers Operators Enumerations Old-Style Enumerations Structs Conditional Statements if/else Statements switch Statements The Conditional Operator Logical Evaluation Operators Three-Way Comparisons Functions Function Return Type Deduction Current Function’s Name Function Overloading Attributes [[nodiscard]] [[maybe_unused]] [[noreturn]] [[deprecated]] [[likely]] and [[unlikely]] [[assume]] C-Style Arrays std::array std::vector std::pair std::optional Structured Bindings Loops The while Loop The do/while Loop The for Loop The Range-Based for Loop Initializer Lists Strings in C++ C++ as an Object-Oriented Language Defining Classes Using Classes Scope Resolution Uniform Initialization Designated Initializers Pointers and Dynamic Memory The Stack and the Free Store Working with Pointers Dynamically Allocated Arrays Null Pointer Constant The Use of const const as a Qualifier for a Type const Member Functions References Reference Variables Reference Data Members Reference Parameters Reference Return Values Deciding Between References and Pointers const_cast() Exceptions Type Aliases typedefs Type Inference The auto Keyword The decltype Keyword The Standard Library Your First Bigger C++ Program An Employee Records System The Employee Class Employee.cppm Employee.cpp EmployeeTest.cpp The Database Class Database.cppm Database.cpp DatabaseTest.cpp The User Interface Evaluating the Program Summary Exercises Chapter 2 Working with Strings and String Views Dynamic Strings C-Style Strings String Literals Raw String Literals The C++ std::string Class What Is Wrong with C-StyleStrings? Using the std::string Class std::string Literals CTAD with std::vector and Strings Numeric Conversions High-Level Numeric Conversions Low-Level Numeric Conversions The std::string_view Class std::string_view and Temporary Strings std::string_view Literals Nonstandard Strings Formatting and Printing Strings Format Strings Argument Indices Printing to Different Destinations Compile-Time Verification of Format Strings Non-Compile-Time Constant Format Strings Handling Errors in Non-Compile-Time Constant Format Strings Format Specifiers width [fill]align sign # type precision 0 L Formatting Escaped Characters and Strings Formatting Ranges Support for Custom Types Summary Exercises Chapter 3 Coding with Style The Importance of Looking Good Thinking Ahead Elements of Good Style Documenting Your Code Reasons to Write Comments Commenting to Explain Usage Commenting to Explain Complicated Code Commenting to Convey Meta-information Copyright Comment Commenting Styles Commenting Every Line Prefix Comments Fixed-Format Comments Ad Hoc Comments Self-Documenting Code Decomposition Decomposition through Refactoring Decomposition by Design Decomposition in This Book Naming Choosing a Good Name Naming Conventions Counters Prefixes Hungarian Notation Getters and Setters Capitalization Namespaced Constants Using Language Features with Style Use Constants Use References Instead of Pointers Use Custom Exceptions Formatting The Curly Brace Alignment Debate Coming to Blows over Spaces and Parentheses Spaces, Tabs, and Line Breaks Stylistic Challenges Summary Exercises Part II Professional C++ Software Design Chapter 4 Designing Professional C++ Programs What is Programming Design? The Importance of Programming Design Designing For C++ Two Rules for Your Own C++ Designs Abstraction Benefiting from Abstraction Incorporating Abstraction in Your Design Reuse Writing Reusable Code Reusing Designs Reusing Existing Code A Note on Terminology Deciding Whether to Reuse Code or Write It Yourself Advantages to Reusing Code Disadvantages to Reusing Code Putting It Together to Make a Decision Guidelines for Choosing a Library to Reuse Understand the Capabilities and Limitations Understand the Learning Cost Understand the Performance Understand Platform Limitations Understand Licensing Understand Support and Know Where to Find Help Prototype Open-Source Libraries The C++ Standard Library Designing a Chess Program Requirements Design Steps Divide the Program into Subsystems Choose Threading Models Specify Class Hierarchies for Each Subsystem Specify Classes, Data Structures, Algorithms, and Patterns for Each Subsystem Specify Error Handling for Each Subsystem Summary Exercises Chapter 5 Designing with Classes Am I Thinking Procedurally? The Object-Oriented Philosophy Classes Components Properties Behaviors Bringing It All Together Living In a World of Classes Over-Classification Overly General Classes Class Relationships The Has-a Relationship The Is-a Relationship (Inheritance) Inheritance Techniques Polymorphism The Fine Line Between Has-a and Is-a The Not-a Relationship Hierarchies Multiple Inheritance Mixin Classes Summary Exercises Chapter 6 Designing for Reuse The Reuse Philosophy How to Design Reusable Code Use Abstraction Structure Your Code for Optimal Reuse Avoid Combining Unrelated or Logically Separate Concepts Use Templates for Generic Data Structures and Algorithms Provide Appropriate Checks and Safeguards Design for Extensibility Design Usable Interfaces Consider the Audience Consider the Purpose Design Interfaces That Are Easy to Use Design General-Purpose Interfaces Reconciling Generality and Ease of Use Designing a Successful Abstraction The SOLID Principles Summary Exercises Part III C++ Coding the Professional Way Chapter 7 Memory Management Working with Dynamic Memory How to Picture Memory Allocation and Deallocation Using new and delete What About My Good Friend malloc? When Memory Allocation Fails Arrays Arrays of Primitive Types Arrays of Objects Deleting Arrays Multidimensional Arrays Working with Pointers A Mental Model for Pointers Casting with Pointers Array-Pointer Duality Arrays Decay to Pointers Not All Pointers Are Arrays! Low-Level Memory Operations Pointer Arithmetic Custom Memory Management Garbage Collection Object Pools Common Memory Pitfalls Underallocating Data Buffers and Out-of-Bounds Memory Access Memory Leaks Finding and Fixing Memory Leaks in Windows with Visual C++ Finding and Fixing Memory Leaks in Linux with Valgrind Double-Deletion and Invalid Pointers Smart Pointers unique_ptr Creating unique_ptrs Using unique_ptrs unique_ptr and C-StyleArrays Custom Deleters shared_ptr Creating and Using shared_ptrs The Need for Reference Counting Casting a shared_ptr Aliasing weak_ptr Passing to Functions Returning from Functions enable_shared_from_this Interoperability of Smart Pointers with C-Style Functions The Old and Removed auto_ptr Summary Exercises Chapter 8 Gaining Proficiency with Classes and Objects Introducing the Spreadsheet Example Writing Classes Class Definitions Class Members Access Control Order of Declarations In-Class Member Initializers Defining Member Functions Accessing Data Members Calling Other Member Functions Using Objects Objects on the Stack Objects on the Free Store The this Pointer Explicit Object Parameter Understanding Object Life Cycles Object Creation Writing Constructors Using Constructors Providing Multiple Constructors Default Constructors Constructor Initializers aka Ctor-Initializers Copy Constructors Initializer-List Constructors Delegating Constructors Converting Constructors and Explicit Constructors Summary of Compiler-Generated Constructors Object Destruction Assigning to Objects Declaring an Assignment Operator Defining an Assignment Operator Explicitly Defaulted and Deleted Assignment Operator Compiler-Generated Copy Constructor and Copy Assignment Operator Distinguishing Copying from Assignment Objects as Return Values Copy Constructors and Object Members Summary Exercises Chapter 9 Mastering Classes and Objects Friends Dynamic Memory Allocation in Objects The Spreadsheet Class Freeing Memory with Destructors Handling Copying and Assignment The Spreadsheet Copy Constructor The Spreadsheet Assignment Operator Disallowing Assignment and Pass-by-Value Handling Moving with Move Semantics Rvalue References Decay Copy Implementing Move Semantics Testing the Spreadsheet Move Operations Implementing a Swap Function with Move Semantics Using std::move() in Return Statements Optimal Way to Pass Arguments to Functions Rule of Zero More About Member Functions static Member Functions const Member Functions mutable Data Members Member Function Overloading Overloading Based on const Explicitly Deleting Overloads Ref-Qualified Member Functions Inline Member Functions Default Arguments Constexpr and Consteval The constexpr Keyword The consteval Keyword constexpr and consteval Classes Different Kinds of Data Members static Data Members Inline Variables Accessing static Data Members from within Class Member Functions constexpr static Data Members Accessing static Data Members from Outside Class Member Functions Reference Data Members Nested Classes Enumerations Inside Classes Operator Overloading Example: Implementing Addition for SpreadsheetCells First Attempt: The add Member Function Second Attempt: Overloaded operator+ as a Member Function Third Attempt: Global operator+ Overloading Arithmetic Operators Overloading the Arithmetic Shorthand Operators Overloading Comparison Operators Overloading Comparison Operators Before C++20 Overloading Comparison Operators Since C++20 Compiler-Generated Comparison Operators Building Stable Interfaces Using Interface and Implementation Classes Summary Exercises Chapter 10 Discovering Inheritance Techniques Building Classes with Inheritance Extending Classes A Client’s View of Inheritance A Derived Class’s View of Inheritance Preventing Inheritance Overriding Member Functions The virtual Keyword Syntax for Overriding a Member Function A Client’s View of Overridden Member Functions The override Keyword The Truth about virtual Preventing Overriding Inheritance For Reuse The WeatherPrediction Class Adding Functionality in a Derived Class Replacing Functionality in a Derived Class Respect Your Parents Parent Constructors Parent Destructors virtual Member Function Calls within Constructors and Destructor Referring to Parent Names Casting Up and Down Inheritance for Polymorphism Return of the Spreadsheet Designing the Polymorphic Spreadsheet Cell The SpreadsheetCell Base Class A First Attempt Pure virtual Member Functions and Abstract Base Classes The Individual Derived Classes StringSpreadsheetCell Class Definition StringSpreadsheetCell Implementation DoubleSpreadsheetCell Class Definition and Implementation Leveraging Polymorphism Future Considerations Providing Implementations for Pure virtual Member Functions Multiple Inheritance Inheriting from Multiple Classes Naming Collisions and Ambiguous Base Classes Name Ambiguity Ambiguous Base Classes Uses for Multiple Inheritance Interesting and Obscure Inheritance Issues Changing the Overridden Member Function’s Return Type Adding Overloads of virtual Base Class Member Functions to Derived Classes Inherited Constructors Hiding of Inherited Constructors Inherited Constructors and Multiple Inheritance Initialization of Data Members Special Cases in Overriding Member Functions The Base Class Member Function Is static The Base Class Member Function Is Overloaded The Base Class Member Function Is private The Base Class Member Function Has Default Arguments The Base Class Member Function Has a Different Access Specification Copy Constructors and Assignment Operators in Derived Classes Run-Time Type Facilities Non-public Inheritance Virtual Base Classes Casts static_cast() reinterpret_cast() dynamic_cast() std::bit_cast() Summary of Casts Summary Exercises Chapter 11 Modules, Header Files, and Miscellaneous Topics Modules Unmodularizing Code Standard Named Modules Module Interface Files Module Implementation Files Splitting Interface from Implementation Visibility vs. Reachability Submodules Module Partitions Implementation Partitions Private Module Fragment Header Units Importable Standard Library Headers Preprocessor Directives Preprocessor Macros Linkage Internal Linkage The extern Keyword Header Files One Definition Rule (ODR) Duplicate Definitions Circular Dependencies Querying Existence of Headers Module Import Declarations Feature-Test Macros for Core Language Features The Static Keyword static Data Members and Member Functions static Variables in Functions Order of Initialization of Nonlocal Variables Order of Destruction of Nonlocal Variables C-Style Variable-Length Argument Lists Accessing the Arguments Why You Shouldn’t Use C-Style Variable-Length Argument Lists Summary Exercises Chapter 12 Writing Generic Code with Templates Overview of Templates Class Templates Writing a Class Template Coding Without Templates A Template Grid Class Using the Grid Template How the Compiler Processes Templates Selective/Implicit Instantiation Explicit Instantiation Template Requirements on Types Distributing Template Code Between Files Member Function Definitions in Same File as Class Template Definition Member Function Definitions in Separate File Template Parameters Non-type Template Parameters Default Values for Template Parameters Class Template Argument Deduction Member Function Templates Member Function Templates with Non-type Template Parameters Using Member Function Templates with Explicit Object Parameters to Avoid Code Duplication Class Template Specialization Deriving from Class Templates Inheritance vs. Specialization Alias Templates Function Templates Function Overloads vs. Function Template Function Template Overloading Function Templates as Friends of Class Templates More on Template Type Parameter Deduction Return Type of Function Templates Abbreviated Function Template Syntax Variable Templates Concepts Syntax Constraints Expression Requires Expressions Combining Concept Expressions Predefined Standard Concepts Type-Constrained auto Type Constraints and Function Templates Constraint Subsumption Type Constraints and Class Templates Type Constraints and Class Member Functions Constraint-Based Class Template Specialization and Function Template Overloading Best Practices Summary Exercises Chapter 13 Demystifying C++ I/O Using Streams What Is a Stream, Anyway? Stream Sources and Destinations Output with Streams Output Basics Member Functions of Output Streams Handling Output Errors Output Manipulators Input with Streams Input Basics Handling Input Errors Input Member Functions Input Manipulators Input and Output with Objects Custom Manipulators String Streams Span-Based Streams File Streams Text Mode vs. Binary Mode Jumping Around with seek() and tell() Linking Streams Together Read an Entire File Bidirectional I/O Filesystem Support Library Path Directory Entry Helper Functions Directory Iteration Summary Exercises Chapter 14 Handling Errors Errors and Exceptions What Are Exceptions, Anyway? Why Exceptions in C++ Are a Good Thing Recommendation Exception Mechanics Throwing and Catching Exceptions Exception Types Catching Exception Objects as Reference-to-const Throwing and Catching Multiple Exceptions Matching and const Matching Any Exception Uncaught Exceptions noexcept Specifier noexcept(expression) Specifier noexcept(expression) Operator Throw Lists Exceptions and Polymorphism The Standard Exception Hierarchy Catching Exceptions in a Class Hierarchy Writing Your Own Exception Classes Nested Exceptions Rethrowing Exceptions Stack Unwinding and Cleanup Use Smart Pointers Catch, Cleanup, and Rethrow Source Location Source Location for Logging Automatically Embed a Source Location in Custom Exceptions Stack Trace The Stack Trace Library Automatically Embed a Stack Trace in Custom Exceptions Common Error-Handling Issues Memory Allocation Errors Non-throwing new Customizing Memory Allocation Failure Behavior Errors in Constructors Function-Try-Blocks for Constructors Errors in Destructors Exception Safety Guarantees Summary Exercises Chapter 15 Overloading C++ Operators Overview of Operator Overloading Why Overload Operators? Limitations to Operator Overloading Choices in Operator Overloading Member Function or Global Function Choosing Argument Types Choosing Return Types Choosing Behavior Operators You Shouldn’t Overload Summary of Overloadable Operators Rvalue References Precedence and Associativity Relational Operators Alternative Notation Overloading The Arithmetic Operators Overloading Unary Minus and Unary Plus Overloading Increment and Decrement Overloading the Bitwise and Binary Logical Operators Overloading the Insertion and Extraction Operators Overloading the Subscripting Operator Providing Read-Only Access with operator[] Multidimensional Subscripting Operator Non-integral Array Indices static Subscripting Operator Overloading the Function Call Operator static Function Call Operator Overloading the Dereferencing Operators Implementing operator* Implementing operator–> What in the World Are operator.* and operator–>*? Writing Conversion Operators Operator auto Solving Ambiguity Problems with Explicit Conversion Operators Conversions for Boolean Expressions Overloading the Memory Allocation and Deallocation Operators How new and delete Really Work The New-Expression and operator new The Delete-Expression and operator delete Overloading operator new and operator delete Explicitly Deleting or Defaulting operator new and operator delete Overloading operator new and operator delete with Extra Parameters Overloading operator delete with Size of Memory as Parameter Overloading User-Defined Literal Operators Standard Library Literals User-Defined Literals Cooked-Mode Literal Operator Raw-Mode Literal Operator Summary Exercises Chapter 16 Overview of the C++ Standard Library Coding Principles Use of Templates Use of Operator Overloading Overview of the C++ Standard Library Strings Regular Expressions I/O Streams Smart Pointers Exceptions Standard Integer Types Numerics Library Integer Comparisons Bit Manipulation Time and Date Utilities Random Numbers Initializer Lists Pair and Tuple Vocabulary Types Function Objects Filesystem Multithreading Type Traits Standard Library Feature-Test MacrosSource Location Stack Trace Containers Sequential Containers Sequential Views Container Adapters Ordered Associative Containers Unordered Associative Containers/Hash Tables Flat Associative Container Adapters bitset Summary of Standard Library Containers Algorithms Non-modifying Sequence Algorithms Modifying Sequence Algorithms Operational Algorithms Swap Algorithms Partitioning Algorithms Sorting Algorithms Binary Search Algorithms Set Algorithms on Sorted Sequences Other Algorithms on Sorted Sequences Heap Algorithms Minimum/Maximum Algorithms Numerical Processing Algorithms Permutation Algorithms Choosing an Algorithm Ranges Library What’s Missing from the Standard Library Summary Exercises Chapter 17 Understanding Iterators and the Ranges Library Iterators Getting Iterators for Containers Iterator Traits Examples Function Dispatching Using Iterator Traits Stream Iterators Output Stream Iterator: ostream_iterator Input Stream Iterator: istream_iterator Input Stream Iterator: istreambuf_iterator Iterator Adapters Insert Iterators Reverse Iterators Move Iterators Ranges Constrained Algorithms Projection Views Modifying Elements Through a View Mapping Elements Range Factories Input Streams as Views Converting a Range into a Container Summary Exercises Chapter 18 Standard Library Containers Containers Overview Requirements on Elements Exceptions and Error Checking Sequential Containers vector vector Overview vector Details Move Semantics vector Example: A Round-Robin Class The vector Specialization deque list Accessing Elements Iterators Adding and Removing Elements list Size Special list Operations list Example: Determining Enrollment forward_list array Sequential Views span mdspan Container Adapters queue queue Operations queue Example: A Network Packet Buffer priority_queue priority_queue Operations priority_queue Example: An Error Correlator stack stack Operations stack Example: Revised Error Correlator Associative Containers Ordered Associative Containers The pair Utility Class map multimap set multiset Unordered Associative Containers Or Hash Tables Hash Functions unordered_map unordered_multimap unordered_set/unordered_multiset Flat Set and Flat Map Associative Container Adapters Performance of Associative Containers Other Containers Standard C-Style Arrays Strings Streams bitset bitset Basics Bitwise Operators bitset Example: Representing Cable Channels Summary Exercises Chapter 19 Function Pointers, Function Objects, and Lambda Expressions Function Pointers findMatches() Using Function Pointers findMatches() As a Function Template Windows DLLs and Function Pointers Pointers to Member Functions (And Data Members) Function Objects Writing Your First Function Object Function Objects in the Standard Library Arithmetic Function Objects Comparison Function Objects Logical Function Objects Bitwise Function Objects Adapter Function Objects Polymorphic Function Wrappers std::function std::move_only_function Lambda Expressions Syntax Lambda Expressions as Parameters Generic Lambda Expressions Lambda Capture Expressions Templated Lambda Expressions Lambda Expressions as Return Type Lambda Expressions in Unevaluated Contexts Default Construction, Copying, and Assigning Recursive Lambda Expressions Invokers Summary Exercises Chapter 20 Mastering Standard Library Algorithms Overview of Algorithms The find and find_if Algorithms The accumulate Algorithm Move Semantics with Algorithms Algorithm Callbacks Algorithm Details Non-modifying Sequence Algorithms Search Algorithms Specialized Searchers Comparison Algorithms Counting Algorithms Modifying Sequence Algorithms generate transform copy move replace erase remove unique shuffle sample reverse Shifting Elements Operational Algorithms for_each for_each_n Partition Algorithms Sorting Algorithms Binary Search Algorithms Set Algorithms Minimum/Maximum Algorithms Parallel Algorithms Numerical Processing Algorithms iota Reduce Algorithms Scan Algorithms Constrained Algorithms Constrained find Constrained generate Constrained for_each Constrained-Only Algorithms Summary Exercises Chapter 21 String Localization and Regular Expressions Localization Wide Characters Non-Western Character Sets Localizing String Literals Locales and Facets Locales Global Locale Using Locales Character Classification Character Conversion Using Facets Conversions Regular Expressions ECMAScript Syntax Anchor Wildcard Alternation Grouping Quantifier Precedence Character Set Matches Word Boundary Back Reference Lookahead Regular Expressions and Raw String Literals Common Regular Expressions The regex Library regex_match() regex_match() Examples regex_search() regex_search() Examples regex_iterator regex_iterator Examples regex_token_iterator regex_token_iterator Examples regex_replace() regex_replace() Examples Summary Exercises Chapter 22 Date and Time Utilities Compile-Time Rational Numbers Duration Examples and Converting Durations Predefined Durations Standard Literals hh_mm_ss Clock Printing Current Time Execution Timing Time Point Date Creating Dates Printing Dates Arithmetic with Dates Time Zone Summary EXERCISES Chapter 23 Random Number Facilities C-Style Random Number Generation Random Number Engines Random Number Engine Adapters Predefined Engines and Engine Adapters Generating Random Numbers Random Number Distributions Summary Exercises Chapter 24 Additional Vocabulary Types Variant Any Tuple Decompose Tuples Structured Bindings tie Concatenation Comparisons make_from_tuple apply Optional: Monadic Operations Expected Exceptions, Error Return Codes, and expected Summary Exercises Part IV Mastering Advanced Features of C++ Chapter 25 Customizing and Extending the Standard Library Allocators Extending the Standard Library Why Extend the Standard Library? Writing a Standard Library Algorithm find_all Modernized find_all Writing a Standard Library Container A Basic Directed Graph Making directed_graph a Standard Library Container Additional Standard Library–Like Functionality Further Improvements Other Container Types Summary Exercises Chapter 26 Advanced Templates More About Template Parameters More About Template Type Parameters Introducing Template Template Parameters More About Non-type Template Parameters Class Template Partial Specialization Emulating Function Partial Specialization with Overloading Template Recursion An N-Dimensional Grid: First Attempt A Real N-Dimensional Grid Variadic Templates Type-Safe Variable-Length Argument Lists constexpr if Variable Number of Mixin Classes Fold Expressions Metaprogramming Factorial at Compile Time Loop Unrolling Printing Tuples constexpr if Using a Compile-Time Integer Sequence with Folding Type Traits Using Type Categories Using Type Relationships Using the conditional Type Trait Using Type Modification Type Traits Using enable_if Using constexpr if to Simplify enable_if Constructs Logical Operator Traits Static Assertions Metaprogramming Conclusion Summary Exercises Chapter 27 Multithreaded Programming with C++ Introduction Race Conditions Tearing Deadlocks False Sharing Threads Thread with Function Pointer Thread with Function Object Thread with Lambda Thread with Member Function Pointer Thread-Local Storage Canceling Threads Automatically Joining Threads Cooperative Cancellation Retrieving Results from Threads Copying and Rethrowing Exceptions Atomic Operations Library Atomic Operations Atomic Smart Pointers Atomic References Using Atomic Types Waiting on Atomic Variables Mutual Exclusion Mutex Classes Spinlock Non-timed Mutex Classes Timed Mutex Classes Locks lock_guard unique_lock shared_lock Acquiring Multiple Locks at Once scoped_lock std::call_once Examples Using Mutexes Thread-Safe Writing to Streams Double-Checked Locking Condition Variables Spurious Wake-Ups Using Condition Variables Latches Barriers Semaphores Futures std::promise and std::future std::packaged_task std::async Exception Handling std::shared_future Example: Multithreaded Logger Class Thread Pools Coroutines Threading Design and Best Practices Summary Exercises Part V C++ Software Engineering Chapter 28 Maximizing Software Engineering Methods The Need for Process Software Life Cycle Models The Waterfall Model Benefits of the Waterfall Model Drawbacks of the Waterfall Model Sashimi Model Spiral-like Models Benefits of a Spiral-like Model Drawbacks of a Spiral-like Model Agile Software Engineering Methodologies Scrum Roles The Process Benefits of Scrum Drawbacks of Scrum The Unified Process The Rational Unified Process RUP as a Product RUP as a Process RUP in Practice Extreme Programming XP in Theory XP in Practice Software Triage Building Your Own Process and Methodology Be Open to New Ideas Bring New Ideas to the Table Recognize What Works and What Doesn’t Work Don’t Be a Renegade Version Control Summary Exercises Chapter 29 Writing Efficient C++ Overview of Performance and Efficiency Two Approaches to Efficiency Two Kinds of Programs Is C++ an Inefficient Language? Language-Level Efficiency Handle Objects Efficiently Pass-by-Value or Pass-by-Reference Return-by-Value or Return-by-Reference Catch Exceptions by Reference Use Move Semantics Avoid Creating Temporary Objects Pre-allocate Memory Use Inline Functions Mark Unreachable Code Design-Level Efficiency Cache Where Necessary Use Object Pools An Object Pool Implementation Using the Object Pool Profiling Profiling Example with gprof First Design Attempt Profiling the First Design Attempt Second Design Attempt Profiling the Second Design Attempt Profiling Example with Visual C++ 2022 Summary Exercises Chapter 30 Becoming Adept at Testing Quality Control Whose Responsibility Is Testing? The Life Cycle of a Bug Bug-Tracking Tools Unit Testing Approaches to Unit Testing The Unit Testing Process Define the Granularity of Your Tests Brainstorm the Individual Tests Create Sample Data and Results Write the Tests Run the Tests Unit Testing in Action Introducing the Microsoft Visual C++ Testing Framework Writing the First Test Building and Running Tests Negative Tests Adding the Real Tests Debugging Tests Basking in the Glorious Light of Unit Test Results Fuzz Testing Higher-Level Testing Integration Tests Sample Integration Tests Integration Testing Techniques System Tests Regression Tests Tips For Successful Testing Summary Exercises Chapter 31 Conquering Debugging The Fundamental Law of Debugging Bug Taxonomies Avoid Bugs Plan For Bugs Error Logging Debug Traces Debug Mode Ring Buffers Assertions Crash Dumps Debugging Techniques Reproducing Bugs Debugging Reproducible Bugs Debugging Nonreproducible Bugs Debugging Regressions Debugging Memory Problems Categories of Memory Errors Tips for Debugging Memory Errors Debugging Multithreaded Programs Debugging Example: Article Citations Buggy Implementation of an ArticleCitations Class Testing the ArticleCitations Class Lessons from the ArticleCitations Example Summary Exercises Chapter 32 Incorporating Design Techniques and Frameworks “I Can Never Remember How To. . .” . . .Write a Class . . .Derive from an Existing Class . . .Write a Lambda Expression . . .Use the Copy-and-Swap Idiom . . .Throw and Catch Exceptions . . .Write a Class Template . . .Constrain Template Parameters . . .Write to a File . . .Read from a File There Must Be a Better Way Resource Acquisition Is Initialization Double Dispatch Attempt #1: Brute Force Attempt #2: Single Polymorphism with Overloading Attempt #3: Double Dispatch Mixin Classes Using Multiple Inheritance Using Class Templates Using CRTP Using CRTP and Deducing this Object-Oriented Frameworks Working with Frameworks The Model-View-Controller Paradigm Summary Exercises Chapter 33 Applying Design Patterns The Strategy Pattern Example: A Logging Mechanism Implementation of a Strategy-Based Logger Using the Strategy-Based Logger The Abstract Factory Pattern Example: A Car Factory Simulation Implementation of an Abstract Factory Using an Abstract Factory The Factory Method Pattern Example: A Second Car Factory Simulation Implementation of a Factory Method Using a Factory Method Other Uses Other Factory Patterns The Adapter Pattern Example: Adapting a Logger Class Implementation of an Adapter Using an Adapter The Proxy Pattern Example: Hiding Network Connectivity Issues Implementation of a Proxy Using a Proxy The Iterator Pattern The Observer Pattern Example: Exposing Events from Subjects Implementation of an Observable Using an Observer The Decorator Pattern Example: Defining Styles in Web Pages Implementation of a Decorator Using a Decorator The Chain of Responsibility Pattern Example: Event Handling Implementation of a Chain of Responsibility Using a Chain of Responsibility The Singleton Pattern Example: A Logging Mechanism Implementation of a Singleton Using a Singleton Summary Exercises Chapter 34 Developing Cross-Platform and Cross-Language Applications Cross-Platform Development Architecture Issues Size of Integers Binary Compatibility Address Sizes Byte Order Implementation Issues Compiler Quirks and Extensions Library Implementations Handling Different Implementations Platform-Specific Features Cross-Language Development Mixing C and C++ Shifting Paradigms Linking with C Code Calling C++ Code from C# Use C# Code from C++ and C++ from C# with C++/CLI Calling C++ Code from Java with JNI Calling Scripts from C++ Code Calling C++ Code from Scripts A Practical Example: Encrypting Passwords Calling Assembly Code from C++ Summary Exercises Part VI Appendices Appendix A C++ Interviews Chapter 1: A Crash Course in C++ and the Standard Library Things to Remember Types of Questions Chapters 2 and 21: Working with Strings and String Views, and String Localization and Regular Expressions Things to Remember Types of Questions Chapter 3: Coding with Style Things to Remember Types of Questions Chapter 4: Designing Professional C++ Programs Things to Remember Types of Questions Chapter 5: Designing with Classes Things to Remember Types of Questions Chapter 6: Designing for Reuse Things to Remember Types of Questions Chapter 7: Memory Management Things to Remember Types of Questions Chapters 8 and 9: Gaining Proficiency with Classes and Objects, and Mastering Classes and Objects Things to Remember Types of Questions Chapter 10: Discovering Inheritance Techniques Things to Remember Types of Questions Chapter 11: Modules, Header Files, and Miscellaneous Topics Things to Remember Types of Questions Chapters 12 and 26: Writing Generic Code with Templates, and Advanced Templates Things to Remember Types of Questions Chapter 13: Demystifying C++ I/O Things to Remember Types of Questions Chapter 14: Handling Errors Things to Remember Types of Questions Chapter 15: Overloading C++ Operators Things to Remember Types of Questions Chapters 16–20 and 25: The Standard Library Things to Remember Types of Questions Chapter 22: Date and Time Utilities Things to Remember Types of Questions Chapter 23: Random Number Facilities Things to Remember Types of Questions Chapter 24: Additional Vocabulary Types Things to Remember Types of Questions Chapter 27: Multithreaded Programming with C++ Things to Remember Types of Questions Chapter 28: Maximizing Software Engineering Methods Things to Remember Types of Questions Chapter 29: Writing Efficient C++ Things to Remember Types of Questions Chapter 30: Becoming Adept at Testing Things to Remember Types of Questions Chapter 31: Conquering Debugging Things to Remember Types of Questions Chapter 32: Incorporating Design Techniques and Frameworks Chapter 33: Applying Design Patterns Things to Remember Types of Questions Chapter 34: Developing Cross-Platform and Cross-Language Applications Things to Remember Types of Questions Appendix B Annotated Bibliography C++ Beginning C++ Without Previous Programming Experience Beginning C++ with Previous Programming Experience General C++ I/O Streams and Strings The C++ Standard Library C++ Templates C++11/C++14/C++17/C++20/C++23 Unified Modeling Language Algorithms and Data Structures Random Numbers Open-Source Software Software Engineering Methodology Programming Style Computer Architecture Efficiency Testing Debugging Design Patterns Operating Systems Multithreaded Programming Appendix C Standard Library Header Files The C Standard Library Containers Algorithms, Iterators, Ranges, and Allocators General Utilities Mathematical Utilities Exceptions I/O streams Threading Support Library Appendix D Introduction to UML Diagram Types Class Diagrams Class Representation Relationship Representation Interaction Diagrams Sequence Diagrams Index EULA