Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
Copyright 2021 Pearson Education, Inc.
All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearson.com/permissions.
Preface
Welcome to the C++ programming language and C++20 for Programmers. This book presents leading-edge computing technologies for software developers.
These are exciting times in the programming-languages community with each of the major languages striving to keep pace with compelling new programming technologies. The ISO C++ Standards Committee now releases a new standard every three years and the compiler vendors implement the new features promptly. C++20 for Programmers is based on the new C++20 standard.
Live-Code Approach
At the heart of the book is the Deitel signature live-code approach. We present most concepts in the context of complete working programs followed by one or more sample executions. Read the Before You Begin section that follows this Preface to learn how to set up your Windows, macOS or Linux computer to run the hundreds of code examples. All the source code is available at
https://www.deitel.com/c-plus-plus-20-for-programmers
We recommend that you compile and run each program as you study it.
Rough-Cut E-Book for OReilly Online Learning Subscribers
You are viewing an early-access rough cut of C++20 for Programmers. We prepared this content carefully, but it has not yet been reviewed or copy edited and is subject to change. As we complete each chapter, well post it here. Please send any corrections, comments, questions and suggestions for improvement to and Ill respond promptly. Check here frequently for updates.
Sneak Peek Videos for OReilly Online Learning Subscribers
As an OReilly Online Learning subscriber, you also have access to the sneak peek of our new C++20 Fundamentals LiveLessons videos at:
https://learning.oreilly.com/videos/c-20-fundamentals-parts/9780136875185
Co-author Paul Deitel immediately records each video lesson as we complete each rough-cut e-book chapter. Lessons go live on OReilly Online Learning a few days later. Again, check here frequently for updates.
Modern C++
The C++ programming language is popular for developing systems software, embedded systems, operating systems, real-time systems, computer games, communications systems and other high-performance computer applications. C++20 for Programmers is an introductory-through-intermediate-level, professional tutorial presentation of C++. The book is not a full-language reference manual, nor is it a cookbook. We focus on Modern C++, which consists of the four most recent C++ standardsC++11, C++14, C++17 and C++20. Throughout the book, features from these standards are marked with icons in the margins like the 20 icon shown here.
Compilers
We tested every program in the book on three popular free compilers:
Visual C++ in Microsoft Visual Studio Community edition on Windows,
Clang in Xcode on macOS, and
GNU C++ on Linux and in the GNU Compiler Collection (GCC) Docker container.
At the time of this writing, some C++20 features are fully implemented in all three compilers, some are implemented in a subset of the three and some are not implemented at all. We point out these issues as appropriate and will update our online content as the compiler vendors implement the rest of C++20s features. C++20 compiler support for many more compilers is tracked at
https://en.cppreference.com/w/cpp/compiler_support
Well also post updates on the books website at
https://deitel.com/books/c-plus-plus-20-for-programmers
Target Audiences
C++20 for Programmers and our C++20 Fundamentals LiveLessons videos have several target audiences:
Non-C++ software developers who are about to do a C++ project and want to learn the latest version of the language, C++20, in the context of a professional-style, language tutorial.
Software developers who may have learned C++ in college or used it professionally some time ago and want to refresh their C++ knowledge in the context of C++20.
C++ software developers who want to learn C++20 in the context of a professional-style, language tutorial.
PERF
SECURITY Focus on Performance and Security Issues
Throughout the book, we call your attention to performance and security issues with the icons you see here in the margin.
Objects Natural Learning Approach
In your C++ programs, youll create and use many objects of carefully-developed-and-tested preexisting classes that enable you to perform significant tasks with minimal code. These classes typically come from:
the C++ Standard Library,
platform-specific libraries, such as those provided by Microsoft Windows, Apple macOS or various Linux versions,
free third-party C++ libraries, often created by the open-source community, and
libraries created by fellow developers, such as those in your organization.
To help you appreciate this style of programming, early in the book youll create and use objects of preexisting classes before creating your own custom classes in later chapters. We call this the objects natural approach.
Our Objects Natural Learning Approach evolved organically as we worked on our Python for Programmers book (https://learning.oreilly.com/library/view/python-for-programmers/9780135231364/
) and our Python Fundamentals LiveLessons videos (https://learning.oreilly.com/videos/python-fundamentals/9780135917411
), but C++20 for Programmers is the first book in which were using the term, Objects Natural.
Rough-Cut Table of Contents (Subject to Change)
Contacting the Authors
As you read the book, if you have questions, were easy to reach at