Discovering Modern C++, 2nd Edition

Book description

Write Powerful, Modern C++ Code for Scientific, Engineering, and Embedded Applications

Discovering Modern C++, Second Edition, will help you master valuable skills for programming with C++ at nearly every level, from "close to the hardware" to high-level abstractions.

Updated for C++17 and C++ 20, this intensive introduction teaches C++ using realistic examples from diverse technical problem domains. Drawing on extensive experience teaching C++ to physicists, mathematicians, engineers, and students, Peter Gottschling guides you smoothly to sophisticated approaches based on advanced features.

Whatever your programming experience, you'll rapidly master increasingly powerful features, from lambdas to expression and variadic templates. Gottschling also shows you how to apply C++'s libraries: both the Standard Template Library (STL) and scientific libraries for arithmetic, linear algebra, differential equations, and graphs. Step by step, you'll learn to write clear and expressive code using object orientation, generics, metaprogramming, and procedural techniques, and master all the abstractions you need to write high-quality, well-performing software.

  • Quickly master core features: variables, operators, expressions, statements, functions, error handling, I/O, arrays, pointers, references, and more

  • Make the most of classes and object-oriented programming, from constructors/destructors to operator overloading and multiple inheritance

  • Apply advanced generic programming and template-based techniques

  • Use C++s libraries to write more robust and powerful code more quickly

  • Explore metaprogramming in depth, and master cutting-edge optimization techniques

  • Walk through representative scientific projects, and create your own

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Dedication Page
  7. Contents
  8. Preface
    1. Reasons to Learn C++
    2. Reasons to Read This Book
    3. The Beauty and the Beast
    4. Languages in Science and Engineering
    5. Typographical Conventions
  9. Pearson’s Commitment to Diversity, Equity, and Inclusion
  10. Acknowledgments
  11. About the Author
  12. Chapter 1. C++ Basics
    1. 1.1 Our First Program
    2. 1.2 Variables
    3. 1.3 Operators
    4. 1.4 Expressions and Statements
    5. 1.5 Functions
    6. 1.6 Error Handling
    7. 1.7 I/O
    8. 1.8 Arrays, Pointers, and References
    9. 1.9 Structuring Software Projects
    10. 1.10 Exercises
  13. Chapter 2. Classes
    1. 2.1 Program for Universal Meaning, Not Technical Details
    2. 2.2 Members
    3. 2.3 Setting Values: Constructors and Assignments
    4. 2.4 Destructors
    5. 2.5 Method Generation Summary
    6. 2.6 Accessing Member Variables
    7. 2.7 Operator Overloading Design
    8. 2.8 Exercises
  14. Chapter 3. Generic Programming
    1. 3.1 Function Templates
    2. 3.2 Namespaces and Function Lookup
    3. 3.3 Class Templates
    4. 3.4 Type Deduction and Definition
    5. 3.5 Template Specialization
    6. 3.6 Non-Type Parameters for Templates
    7. 3.7 Functors
    8. 3.8 Lambda
    9. 3.9 Variable Templates
    10. 3.10 Programming with Concept(s)
    11. 3.11 Variadic Templates
    12. 3.12 Exercises
  15. Chapter 4. Libraries
    1. 4.1 Standard Template Library
    2. 4.2 Numerics
    3. 4.3 Meta-programming
    4. 4.4 Utilities
    5. 4.5 The Time Is Now
    6. 4.6 Concurrency
    7. 4.7 Scientific Libraries Beyond the Standard
    8. 4.8 Exercises
  16. Chapter 5. Meta-Programming
    1. 5.1 Let the Compiler Compute
    2. 5.2 Providing and Using Type Information
    3. 5.3 Expression Templates
    4. 5.4 Meta-Tuning: Write Your Own Compiler Optimization
    5. 5.5 Optimizing with Semantic Concepts
    6. 5.6 Turing Completeness
    7. 5.7 Exercises
  17. Chapter 6. Object-Oriented Programming
    1. 6.1 Basic Principles
    2. 6.2 Removing Redundancy
    3. 6.3 Multiple Inheritance
    4. 6.4 Dynamic Selection by Sub-typing
    5. 6.5 Conversion
    6. 6.6 Advanced Techniques
    7. 6.7 Exercises
  18. Chapter 7. Scientific Projects
    1. 7.1 Implementation of ODE Solvers
    2. 7.2 Creating Projects
    3. 7.3 Modules
    4. 7.4 Some Final Words
  19. Appendix A: Clumsy Stuff
    1. A.1 More Good and Bad Scientific Software
    2. A.2 Basics in Detail
    3. A.3 Real-World Example: Matrix Inversion
    4. A.4 Class Details
    5. A.5 Method Generation
    6. A.6 Template Details
    7. A.7 More on Libraries
    8. A.8 Dynamic Selection in Old Style
    9. A.9 More about Meta-Programming
    10. A.10 Linking to C Code
  20. Appendix B: Programming Tools
    1. B.1 g++
    2. B.2 Debugging
    3. B.3 Memory Analysis
    4. B.4 gnuplot
    5. B.5 Unix, Linux, and Mac OS
  21. Appendix C: Language Definitions
    1. C.1 Value Categories
    2. C.2 Operator Overview
    3. C.3 Conversion Rules
  22. Bibliography
  23. Subject Index
  24. Code Snippets

Product information

  • Title: Discovering Modern C++, 2nd Edition
  • Author(s): Peter Gottschling
  • Release date: December 2021
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780136798477