C++ Tutorial

© Copyright 2023 by Peter Chapin
Last Revised: August 2023


Introduction

The documents linked to this page constitute the "lectures" of a one-semester course in the C++ programming language (primarily the 1998 standard). I created these documents myself and have used them in programming classes at Vermont State University, where I am an instructor. I am posting these documents on the web for public access under the terms of the GNU Free Documentation License (GFDL).

Permission is granted to copy, distribute and/or modify this document (and the related subordinate documents as described above) under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no invariant sections, no front-cover texts, and no back-cover texts.


Lessons

This course assumes as a prerequisite that you are familiar with C. Teaching C++ on top of a C background is controversial. Some C++ instructors believe that C++ is best taught on its own terms and not as an enhancement to C. Such an approach makes sense because C++ offers different (and better) ways of handling certain problems as compared to C. It can take a while for a seasoned C programmer to break old habits and really start using C++ to its full potential. However, at Vermont State University we teach plain C in an introductory course because we believe there are still many contexts where plain C is all that is available and thus worth learning for its own sake. As a result, our C++ course assumes a C background.

C++ is an enormous language that can be used in many ways. It would be impossible for a single course to cover all of what is C++. In this course, I focus on C++'s support for user-defined types and object-oriented programming. These are important facilities that are in wide use. However, there are many C++ features that I do not describe in detail here. In particular, this course is light on templates and generic programming. It is my hope, however, that after working through the lessons in this course, you will be in a good position to study C++ templates from other sources.

I have broken all of this material into 30 lessons along with some supporting files. Each lesson builds on the previous lessons. I recommend that you read the lessons in order. However, if you have some previous C++ experience, you may find it useful to skip around. In places where it matters, which are few, this course assumes you are using the g++ compiler on a Unix system. In addition, this course assumes you are comfortable editing source code files with a good programmer's editor.

In addition to the lessons themselves, I have also prepared several example programs to help illustrate some points and to show the features of C++ in a more realistic way. In the list below, I show links to these examples as well as to the lesson text. Each example is associated with a particular lesson. You should review an example after you've read the corresponding lesson.

I have also created three review lessons that highlight essential topics from C that you need to know before you'll be able to make sense of the materials in this course. These three review lessons are shown below just before the main list of lessons for this course. If you are interested in my full C course, see the links at the bottom of this page.

Finally, I have prepared a couple of supplementary lessons on using the gdb debugger and the Emacs text editor. These lessons are not about C++ directly, but may be of interest if you are using those tools. The supplementary lessons are at the bottom of the numbered lesson list.

Lessons that review certain topics from C:

Lessons containing the content of this course:

Lessons containing supplementary material:

  1. Lesson EMACS: Using the Emacs text editor.
  2. Lesson DEBUG: Using the gdb debugger.

Videos

The following videos contain various bits of tutorial information. Some videos are of fairly advanced nature.


Slides

The following slides provide supplementary information about various C++ topics.


Links

The following links provide access to potentially useful resources about C++.

Compilers

Tutorials

References

Libraries


© Copyright 2023 by Peter Chapin.
Last Revised: August 4, 2023