C++20 for Programmers
An Objects-Natural Approach
Harvey Deitel author Paul Deitel author
Format:Paperback
Publisher:Pearson Education (US)
Published:9th Jun '22
Should be back in stock very soon
The professional programmer's Deitel® guide to C++20
Written for programmers with a background in another high-level language, in this book, you'll learn Modern C++ development hands on using C++20 and its "Big Four" features--Ranges, Concepts, Modules and Coroutines. (For more details, see the Preface, and the table of contents diagram inside the front cover.)
In the context of 200+, hands-on, real-world code examples, you'll quickly master Modern C++ coding idioms using popular compilers--Visual C++®, GNU® g++, Apple® Xcode® and LLVM®/Clang. After the C++ fundamentals quick start, you'll move on to C++ standard library containers array and vector; functional-style programming with C++20 Ranges and Views; strings, files and regular expressions; object-oriented programming with classes, inheritance, runtime polymorphism and static polymorphism; operator overloading, copy/move semantics, RAII and smart pointers; exceptions and a look forward to C++23 Contracts; standard library containers, iterators and algorithms; templates, C++20 Concepts and metaprogramming; C++20 Modules and large-scale development; and concurrency, parallelism, the C++17 and C++20 parallel standard library algorithms and C++20 Coroutines.
Features
- Rich coverage of C++20's "Big Four": Ranges, Concepts, Modules and Coroutines
- Objects-Natural Approach: Use standard libraries and open-source libraries to build significant applications with minimal code
- Hundreds of real-world, live-code examples
- Modern C++: C++20, 17, 14, 11 and a look to C++23
- Compilers: Visual C++®, GNU® g++, Apple Xcode® Clang, LLVM®/Clang
- Docker: GNU® GCC, LLVM®/Clang
- Fundamentals: Control statements, functions, strings, references, pointers, files, exceptions
- Object-oriented programming: Classes, objects, inheritance, runtime and static polymorphism, operator overloading, copy/move semantics, RAII, smart pointers
- Functional-style programming: C++20 Ranges and Views, lambda expressions
- Generic programming: Templates, C++20 Concepts and metaprogramming
- C++20 Modules: Large-Scale Development
- Concurrent programming: Concurrency, multithreading, parallel algorithms, C++20 Coroutines, coroutines support libraries, C++23 executors
- Future: A look forward to Contracts, range-based parallel algorithms, standard library coroutine support and more
"C++20 for Programmers builds up an intuition for modern C++ that every programmer should have in the current software engineering ecosystem. The unique and brilliant ordering in which the Deitels present the material jibes much more naturally with the demands of modern, production-grade programming environments. I strongly recommend this book for anyone who needs to get up to speed on C++, particularly in professional programming environments where the idioms and patterns of modern C++ can be indecipherable without the carefully crafted guidance that this book provides."
--Dr. Daisy Hollman, ISO C++ Standards Committee Member
From Marc Gregoire, Software Architect, Nikon Metrology, Microsoft Visual C++ MVP and Author of Professional C++, 5/e:
"C++20 is a big update for the C++ language and its standard library, introducing numerous new features. Some of these will drastically change the way we write and organize our code. C++20 for Programmers is a great book to learn C++. This latest edition is updated to include new C++20 features bringing you up to speed with writing modern and well-structured C++ code. Everything is introduced in an easy-to-read, step-by-step manner with the aid of compact, to-the-point code examples. I like the objects-natural approach and examples. For example, the ZIP discussion shows how powerful it is to use third-party libraries that implement complicated things--this allows you to write and read ZIP files in just a few lines of your own code. Another very nice and interesting objects-natural example shows encrypting and decrypting text with just a few lines of code."
"I especially like that you've stressed to avoid using pointers but instead use modern functionality such as std::array, std::vector, std::string, and so on. I also like the very nice objects natural section, explaining std::span. A nice introduction to containers, iterators, and algorithms, the range-based for loop, and functional programming. Good introduction to classes. Good discussion of modern runtime- and compile-time polymorphism techniques. A very good chapter on operator overloading. Nice exceptions chapter--I like the look ahead to contracts for C++23 or later! I like the chapter 'Templates, C++20 Concepts and Metaprogramming.' It touches on several more advanced features, but it is still easy to read and to follow the examples. Nice chapter on C++20 modules--it contains just the right amount of details for this book."
From Dr. Daisy Hollman, ISO C++ Standards Committee Member:
"I'm a big fan of talking about objects early and often--it's nice to see that my pedagogical instincts in this matter are supported by at least some experts. :-) I love the emphasis on code readability throughout. The emphasis on safe programming in this book is excellent. I really like the 'objects natural' case study with the zip library. I'm a big fan of introducing the class template array before the language version of arrays, and I also like the use of vector as a case study. I absolutely love the emphasis on avoiding pointers. Well done! I'm also a big fan of the section on span. The use of std::string_view in Figure 9.2 is exactly what we had in mind when we designed it."
"In the chapter, 'OOP: Inheritance and Runtime Polymorphism,' it's awesome that NVI (non-virtual interface idiom) is covered. I really like the discussion of real-world consequences of implementation inheritance. 'Operator Overloading, Copy/Move Semantics and Smart Pointers' is a great chapter."
From Inbal Levi, SolarEdge Technologies, ISO C++ Foundation director, ISO C++ SG9 (Ranges) chair, ISO C++ Standards Committee:
" C++20 for Programmers provides a great introduction to C++20 through simple and useful examples. 'C++20 formatting with the {fmt} library' is a great and important explanation--it clarifies the relation between standard library implementations and open-source libraries. Examples (especially cryptography) in the 'Functions and an Intro to Function Templates' chapter are great. The chapter, 'Strings, string_views, Text Files, CSV Files and Regex' is well written, great examples. I think both the use case and the reference to OWASP (Open Web Application Security Project) as a knowledge resource will do a great deal for the new developer. The chapter 'OOP: Inheritance and Runtime Polymorphism,' presents some very interesting design patterns. The chapter, 'Operator Overloading, Copy/Move Semantics and Smart Pointers,' is great, the explanations and example class are good and informative."
From Danny Kalev, Ph.D. and Certified System Analyst and Software Engineer, Former ISO C++ Standards Committee Member:
"The Deitels have included all of the useful new C++20 features in a readable and up-to-date book with numerous code examples aimed to transport you swiftly and smoothly into the era of Modern C++ programming. The code has been rigorously tested with three leading compilers. Covers the latest C++20 programming and design idioms. All the relevant hands-on knowledge for designing efficient and reusable concurrent C++20 apps."
"The chapter, 'Strings, string_views, Text Files, CSV Files and Regex,' is one of the best chapters in any C++ book I've read. Kudos on the Titanic dataset. 'Operator Overloading, Copy/Move Semantics and Smart Pointers' discusses the Special Five member functions, emphasizing the differences between copy constructors and assignment operators, and between copying and moving. The chapter, 'Standard Library Containers and Iterators,' covers the major concepts of standard library containers, iterators, algorithms and container adaptors--all with C++20-compliant code. The chapter, 'Standard Library Algorithms and C++20 Ranges & Views,' covers advanced C++20 features, including iterators and their requirements, the C++20 ranges facilities and related algorithms, functional programming using functors and lambdas, and brief discussion about parallelization. 'Templates, C++20 Concepts and Metaprogramming' is one of the best chapters of this book. Not only is it clear and easy to read, it's also up to date with the latest C++20 features. The new C++20 concepts are explained and demonstrated very well, as are variadic templates, the more traditional notion of type traits and finally, the pick of the crop is template metaprogramming. Writing about modules is quite a challenge--this chapter presents them clearly and in detail. I loved the jaw-dropping improvement in translation unit sizes achieved by importing a header unit using C++20 modules rather than the preprocessor to include a header."
"Coroutines, one of C++20's 'big four' features, are explained clearly. The main concepts associated with coroutines, i.e., co_await, co_yield and co_return, are demonstrated using easy-to-follow code listings, as are more advanced issues such as tasks and executors. Another noteworthy point is the balanced coverage of third-party coroutines support libraries, since C++20 doesn't provide its own yet."
From Arthur O'Dwyer, C++ trainer, Chair of CppCon's Back to Basics track, author of several accepted C++17/20/23 proposals and the book Mastering the C++17 STL:
"The chapter, 'OOP: Inheritance and Runtime Polymorphism,' is thorough on all the permutations of private, public, data members, function members, virtual, non-virtual, etc. Very obviously concerned with being up-to-date with C++17 and C++20--that's excellent! You emphasize override and final, which is good. You also emphasize 'prefer composition over inheritance' and NVI (non-virtual interface idiom), which I like. I'm very happy that you show the new ways and say they're good. That's great. C++20 Modules are relegated to their own chapter near the end of the book, but their treatment is not superficial; the chapter demonstrates some non-trivial features such as module partitions, and includes step-by-step instructions for building the sample code on all three mainstream implementations. Covers C++20 Concepts and Ranges confidently and in depth. New features such as std::format, std::span and concepts are used heavily throughout the code examples. The fun part of the chapter, 'Control Statements: Part 1,' is integrating the third-party libraries [in the objects-natural case study] and . 'Strings, string_views, Text Files, CSV Files and Regex' is a solid chapter. I like presenting string and string_view together as a unit. The rapidcsv [objects-natural] case study is a really good idea. The chapter 'Exceptions and a Look Forward to Contracts' presents a pretty clear narrative focus on exceptions and error handling. In the chapter 'C++20 Coroutines,' the choice to use tl::generator and concurrencpp::result is good."
From José Antonio González Seco, Parliament of Andalusia:
"Ideal for professionals who want to learn modern C++ or improve their skills with it. Covers C++20 in a clear and practical way, with an impressive amount of high-quality references, a strong focus on performance and security, and an 'objects natural' approach very useful for learning how to integrate external libraries in your projects. Great coverage of modules, with clear explanations."
From Saar Raz, Senior Software Engineer, Swimm.io and Implementor of C++20 Concepts in Clang:
"The chapter 'Templates, C++20 Concepts and Metaprogramming' covers a lot of ground and important features, such as concept-based overloading, fold expressions and constexpr if. It also goes into great detail explaining how the metaprogramming works. The explanation about the need for coroutines is excellent and provides many use cases, building a strong case for the feature. Gives a high level of understanding of the main low-level concepts of coroutine implementation--it helped me better grasp those concepts."
From Anthony Williams, Member of the British Standards Institution C++ Standards Panel, Director of Just Software Solutions Ltd., Author of C++ Concurrency in Action, 2/e:
"Gives concrete information on how to write code using modules. I like that the chapter 'Parallel Algorithms and Concurrency: A High-Level View' doesn't go too deep on the lower-level things and starts with the parallel algorithms. Introduces coroutines clearly, with simple examples using open-source libraries."
From Andreas Fertig, Independent C++ Trainer and Consultant, Creator of cppinsights.io, Author of Programming with C++20:
"Paul and Harvey do an excellent job teaching modern C++ using C++20. Templates are a huge beast and the chapter 'Templates, C++20 Concepts and Metaprogramming' gives a good overview. The chapter 'C++20 Modules: Large-Scale Development' is a good write-up of modules and how they work--it covers all the parts one needs to start with or convert to modules. An excellent introduction to multithreading and concurrency. In the chapter 'C++20 Coroutines,' I especially liked the overview of coroutine use-cases."
Some Reviews from Earlier Editions--and the Reviewers' Affiliations at the Time
"A great introduction to object-oriented programming in C++. I wish I'd had it when I was learning the language. Provides helpful tips that are relevant to real problems in the software industry." --Gordon Hogenson, Microsoft
"I like how the text emphasizes the importance of style, comments and consistency." --Renato Golin, LLVM Compiler Engineer (now a Senior Research Engineer at Microsoft)
"A stellar overview of how polymorphism works--the section on how it's done is great." --Gašper Ažman, A9.com Search Technologies and Co-author, C++ Today: The Beast Is Back
"Gets you into C++ programming quickly with important tips, loads of insights and gradual progression towards advanced concepts. A great tour of C++ for beginners learning an industrial-strength programming language." --Dean Michael Berris, Google, Maintainer of cpp-netlib and Former ISO C++ Committee Member (now a Principal Software Engineer at Microsoft)
"I liked that the material doesn't skirt around the complex nature of C++, and instead explains all the aspects of the example programs." --Jonathan Wakely, Redhat, ISO C++ Committee Secretary
ISBN: 9780136905691
Dimensions: 232mm x 168mm x 45mm
Weight: 1600g
960 pages
3rd edition