Expert C++
Become a proficient programmer by learning coding best practices with C++17 and C++20's latest features
Vardan Grigoryan
Shunguang Wu
BIRMINGHAM - MUMBAI
Expert C++
Copyright 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Richa Trip athi
Acquisition Editor: Denim Pinto
Content Development Editor: Pathikrit Roy
Senior Editor: Rohit Singh
Technical Editor: Romy Dias
Copy Editor: Safis Editing
Project Coordinator: Francy Puthiry
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Production Designer: Alishon Mendonsa
First published: April 2020
Production reference: 1100420
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-83855-265-7
www.packt.com
To my mother, Karine, and to my little princess, Leia, for their encouragement and support.
Vardan Grigoryan
To my wife, Wen, and to my sons, Justin and Zachary.
- Shunguang Wu
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
Vardan Grigoryan is a senior backend engineer and C++ developer with more than 9 years of experience. Vardan started his career as a C++ developer and then moved to the world of server-side backend development. While being involved in designing scalable backend architectures, he always tries to incorporate the use of C++ in critical sections that require the fastest execution time. Vardan loves tackling computer systems and program structures on a deeper level. He believes that true excellence in programming can be achieved by means of a detailed analysis of existing solutions and by designing complex systems.
Shunguang Wu is a senior professional staff at Johns Hopkins University Applied Physics Laboratory, and received his PhDs in theoretical physics and electrical engineering from Northwestern University (China) and Wright State University (USA), respectively. He published about 50 reviewed journal papers in the area of nonlinear dynamics, statistical signal processing and computer vision in his early career. His professional C++ experience started with teaching undergraduate courses in the late 1990s. Since then he has been designing and developing lots of R&D and end-user application software using C++ in world-class academic and industrial laboratories. These projects span both the Windows and Linux platforms.
About the reviewers
Lou Mauget learned to program long ago at Michigan State University as a physics major, learning to use software in designing a cyclotron. Afterward, he worked for 34 years at IBM. He is currently consulting for Keyhole Software of Leawood, Kansas. Lou has coded in C++, Java, JavaScript, Python, and newer languages, as each was conceived. Current interests include reactive functional programming, containers, Node.js, NoSQL, geospatial systems, mobile, and any new language or framework. He has coauthored three computer books. He has written two IBM DeveloperWorks XML tutorials and co-written several J2EE certification tests for IBM. He has been a reviewer for Packt Publishing and others.
Scott Hutchinson leads a team of C++ and F# developers in Oxnard, California. After a few years as a VB/VBA developer, he started developing with .NET Framework immediately after its launch in 2002. Since 2016, he has done most of his development in C++. He is a mentor for the F# track on Exercism, and teaches functional programming in F# to his team at work. His main professional interests are functional programming and machine learning. When he's not learning some new software development skill, he's usually hiking in the mountains of Southern California.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
This book will provide readers with details of C++ programs with regard to the C++17 and C++20 standards, and how they are compiled, linked, and executed. It will also cover how memory management works, what the best practices are as regards memory management problems, what classes are and how they are implemented, how a compiler optimizes code, and what the compiler's approach is in terms of supporting class inheritance, virtual functions, and templates.
The book will also tell readers how to apply memory management, object-oriented programming, concurrency, and design patterns to create world-ready production applications.
Readers will learn the inner details of efficient data structures and algorithms, and will understand how to measure and compare them to choose what fits best for a specific problem.
Next page