Programming in C++ — The C++ Language, Libraries, Tools, and Other Topics
Table of Contents
- Other Textbooks by the Author
- About the Textbook and Lecture Slides
- About the Author
- Obtaining the Textbook and Lecture Slides (E-Book and Print)
- Git Repository
- Software Development Environment (SDE)
- Virtual Machine Disk Images
- Video Presentations
- Additional References
- Solutions Manual
The author also has the following (open-access) textbooks:
- Multiresolution Signal and Geometry Processing: Filter Banks, Wavelets, and Subdivision
- Signals and Systems
The textbook provides a large collection of exercises for learning to program in C++. The lecture slides provide very detailed coverage of the C++ language, standard library, and much more. For more details, please refer to the abstract for the textbook and lecture slides.
For more details about the author, please visit his home page.
The abstract for the textbook (i.e., exercise book) is as follows:
This book presents a large collection of exercises for learning to program in C++. A study plan for learning C++ based on a collection of video lectures and supplemental reading is also provided.
Lecture Slides Abstract
The abstract for the lecture slides is as follows:
This document, which consists of approximately 2900 lecture slides, offers a wealth of information on many topics relevant to programming in C++, including coverage of the C++ language itself, the C++ standard library and a variety of other libraries, numerous software tools, and an assortment of other programming-related topics. The coverage of the C++ language and standard library is current with the C++20 standard.
C++ PROGRAMMING LANGUAGE. Many aspects of the C++ language are covered from introductory to more advanced. This material includes: the preprocessor, language basics (objects, types, values, operators, expressions, control-flow constructs, functions, namespaces, and comparison), classes, templates (function, class, variable, and alias templates, variadic templates, template specialization, and SFINAE), concepts, lambda expressions, inheritance (run-time polymorphism and CRTP), exceptions (exception safety and RAII), smart pointers, memory management (new and delete operators and expressions, placement new, and allocators), rvalue references (move semantics and perfect forwarding), coroutines, concurrency (memory models, and happens-before and synchronizes-with relationships), modules, compile-time computation, and various other topics (e.g., copy elision and initialization).
C++ STANDARD LIBRARY AND VARIOUS OTHER LIBRARIES. Various aspects of the C++ standard library are covered including: containers, iterators, algorithms, ranges, I/O streams, time measurement, and concurrency support (threads, mutexes, condition variables, promises and futures, atomics, and fences). A number of Boost libraries are discussed, including the Intrusive, Iterator, and Container libraries. The OpenGL library and GLSL are discussed at length, along with several related libraries, including: GLFW, GLUT, and GLM. The CGAL library is also discussed in some detail.
SOFTWARE TOOLS. A variety of software tools are discussed, including: static analysis tools (e.g., Clang Tidy and Clang Static Analyzer), code sanitizers (e.g., ASan, LSan, MSan, TSan, and UBSan), debugging and testing tools (e.g., Valgrind, LLVM XRay, and Catch2), performance analysis tools (e.g., Perf, PAPI, Gprof, and Valgrind/Callgrind), build tools (e.g., CMake and Make), version control systems (e.g., Git), code coverage analysis tools (e.g., Gcov, LLVM Cov, and Lcov), online C++ compilers (e.g., Compiler Explorer and C++ Insights), and code completion tools (e.g., YouCompleteMe, and LSP clients/servers).
OTHER TOPICS. An assortment of other programming-related topics are also covered, including: data structures, algorithms, computer arithmetic (e.g., floating-point arithmetic and interval arithmetic), cache-efficient algorithms, vectorization, good programming practices, software documentation, software testing (e.g., static and dynamic testing, and structural coverage analysis), and compilers and linkers (e.g., Itanium C++ ABI).
The textbook and lecture slides are licensed under a
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
This license allows for a work to be distributed freely, subject to
certain quite reasonable conditions (e.g., no commercial use).
Refer to the above link for more details on the license.
Note: New editions of the textbook and/or lecture slides are announced on the author's Twitter feed (@mdadams16).
Each of the textbook and lecture-slide documents is identifed by a edition/version (such as edition "1.0" or version "2021-04-01"). The edition appears on most pages of the document, allowing different editions to be easily distinguished.
All editions of the textbook and lectures slides that are currently available are listed below. All editions of these documents are available in electronic form (i.e., PDF format) for download from this web page. (See below.) Some editions of these documents may also available in print form via online order from the University of Victoria Bookstore.
It is strongly recommended that the most recent edition of the textbook and lecture slides be employed whenever possible, as this edition will typically contain new and improved material as well as corrections that older editions lack.
Textbook (i.e., Exercise Book)
The available editions of the textbook (i.e., exercise book) are as follows:
- Version 2021-04-01 (Most Recent Version)
The available editions of the lecture slides are as follows:
(Most Recent Version)
- M. D. Adams, Lecture Slides for Programming in C++ — The C++ Language, Libraries, Tools, and Other Topics (Version 2021-04-01), University of Victoria, Victoria, BC, Canada, Apr. 2021, xxiii + 2901 slides. ISBN 978-0-9879197-4-8 (ebook).
- M. D. Adams, Lecture Slides for Programming in C++ — The C++ Language, Libraries, Tools, and Other Topics (Version 2020-02-29), University of Victoria, Victoria, BC, Canada, Feb. 2020, xxii + 2543 slides. ISBN 978-1-55058-663-3 (print), ISBN 978-1-55058-664-0 (PDF).
- M. D. Adams, Lecture Slides for Programming in C++ — The C++ Language, Libraries, Tools, and Other Topics (Version 2019-02-04), University of Victoria, Victoria, BC, Canada, Feb. 2019, xxii + 2516 slides. ISBN 978-1-55058-640-4 (print), ISBN 978-1-55058-641-1 (PDF).
- M. D. Adams, Lecture Slides for Programming in C++ — The C++ Language, Libraries, Tools, and Other Topics (Version 2018-02-15), University of Victoria, Victoria, BC, Canada, Feb. 2018, xviii + 2124 slides. ISBN 978-1-55058-624-4 (print), ISBN 978-1-55058-625-1 (PDF).
- M. D. Adams, Lecture Slides for Programming in C++ (Version 2017-02-24), University of Victoria, Victoria, BC, Canada, Feb. 2017, xviii + 1139 slides. ISBN 978-1-55058-608-4 (print), ISBN 978-1-55058-609-1 (PDF).
- M. D. Adams, Lecture Slides for the C++ Programming Language (Version 2016-01-18), University of Victoria, Victoria, BC, Canada, Jan. 2016, xviii + 903 slides. ISBN 978-1-55058-582-7 (paperback), ISBN 978-1-55058-583-4 (PDF).
- M. D. Adams, An Introduction to the C++ Programming Language (Version 2015-02-03), University of Victoria, Victoria, BC, Canada, Feb. 2015, xii + 702 slides. ISBN 978-1-55058-537-7 (paperback), ISBN 978-1-55058-538-4 (PDF).
The lecture slides have a companion Git repository that is hosted by GitHub. This repository contains numerous code examples and programming exercises. The URL for the main web page associated with the repository is:
The author has setup a basic software development environment for C++ called SDE. The SDE includes recent versions of software such as the GCC and Clang compiler tool chains, Boost, Catch2, GDB, GSL, Hub, Lcov, YouCompleteMe (YCM), and Vim LSP. For more information about SDE, refer to the official web site for SDE on GitHub:Virtual Machine Disk Images section. Instructions on how to use the SDE can be found on the (above) SDE web site. If the VM disk images are used (which already have the SDE installed), the step of installing SDE is not needed. To use the SDE, simply use the sde_shell or sde_make_setup command as described in the SDE documentation.
Virtual-machine (VM) disk images are available for various versions of the SDE. If you have a hypervisor (i.e., VM software) on your computer, you may find these disk images to be helpful.
The following VM disk images are available for download:
(Most Recent Version)
- SDE 4.4.1; based on Fedora 33
- The root account can be accessed via sudo from the jdoe account.
- user name: jdoe
- user password: iamjdoe
- SDE installation directory: /opt/sde
- pathname of sde_shell: /opt/sde/bin/sde_shell [Note: To access the SDE, the sde_shell command must be used.]
- SHA512 checksums for disk images
- disk image in (gzipped) QCOW2 format
- disk image in (gzipped) VDI format
- disk image in (gzipped) VMDK format
Which Disk-Image Format to Use. The files with a ".gz" extension are compressed using Gzip and will need to be decompressed before use. If the VM software tool directly uses the disk image file (rather than making a copy of it), ensure that the file is both readable and writeable. The particular disk-image format that should be employed will depend on the specific VM software being used. Some VM software tools support multiple disk image formats. VirtualBox supports the VDI format (and possibly others). Many VM software tools on Linux support the QCOW2 format. VMWare supports the VMDK format (and possibly others).
Which Hypervisor Software to Use. If your computer runs Linux with secure boot enabled, it is recommended that you use GNOME Boxes (to avoid the hassle of having to cryptographically sign the kernel modules used by VirtualBox). Otherwise (e.g., if your computer runs MacOS, Windows, or Linux with secure boot disabled), the use of VirtualBox is recommended, as it generally works well and has a less restrictive license than VMWare Workstation Player.
Enabling Virtualization Support in Firmware. If you are using a hypervisor for the first time on your computer, you may need to enable virtualization in your computer's firmware (sometimes called BIOS), as hypervisor typically requires hardware support for virtualization to be enabled and this support is not always enabled by default. In order to enable this support (if required), you should look for firmware configuration settings that relate to virtualization. For example, for 64-bit Intel x86 processors, Intel-VT (Intel Virtualization Technology) support must be enabled, and for 64-bit AMD x86 processors, AMD-V (AMD Virtualization) support must be enabled.
Video Presentations for Lecture Slides
The following video presentations are available for the lecture slides:
The course SENG 475 (titled "Advanced Programming Techniques for Robust Efficient Computing") was taught using the slide deck available from this web site. All of the lecture content for the course was captured in video format and is available online (via YouTube). An information package for the lecture videos is available that includes:
- the edition of the lecture slides used in the lecture videos
- a fully-cataloged list of the slides covered in the lectures, where each slide in the list has a link to the corresponding time offset in the YouTube video where the slide is covered
- numerous supplemental documents referenced by the slide deck
The catalog of video lectures from the above Zip archive is also directly available through the following links:
Some other references that may be helpful are as follows:
- Video lectures for MIT OCW course on algorithms (Fall 2011).
- Video lectures for MIT OCW course on algorithms (Fall 2005).
- Video lectures for MIT OCW course on advanced data structures (Spring 2012).
- C++20 standard draft document N4861 (which is not the official ISO C++20 standard but should be quite close):
- C++17 standard draft document N4659 (which is not the official ISO C++17 standard but should be quite close):
- C++14 standard draft document N4140 (which is not the official ISO C++14 standard but should be quite close):
- C++11 standard draft document N3337 (which is not the official ISO C++11 standard but should be quite close):
The solutions manual is only available to course instructors. Proof of faculty status is required in order to obtain the solutions manual.
The solutions manual presents solutions for the exercises appearing in the textbook. The current version of the solutions manual only contains solutions for a subset of the exercises. That is, not every exercise in the textbook currently has a corresponding solution in the solutions manual. (Future versions of the solutions manual will add solutions for more of the exercises.)
The versions available are as follows:
(Most Recent Edition)
- M. D. Adams, Solutions Manual for Exercises for Programming in C++, (Version 2021-04-01), University of Victoria, Victoria, BC, Canada, Apr. 2021, iv + 305 pages, ISBN 978-0-9879197-6-2 (PDF).