Teaching "An introduction to C++"
Here we go again.
I took the opportunity to inherit, study, expand and update some introductory material for the course of scientific C++. C++ was my first programming language, learn on the second year bachelor of Physics when studying in Perugia. In a course held by from Prof. Marco Baioletti, in which we started from computer architecture up to classes and polymorphism. From that point, I managed to use this knowledge to use C++ for scripts and then move to Python for its ecosystem. I needed a strong refresh (especially because I was stack at C++11 standard) in order to being able to read and understand (not so trivial in modern C++) code that might finish on my desk at CINECA.
Therefore, I decided to go back studying it and teach a one day course on the language basics.
This was quite challenging given the limited time, the few number of iterations that I had the possibility to do to improve the material and the fact that the exercises were not designed by me. The latter, for me was a lost occasion to have some more fun. Nonetheless, I think the material is in good shape and can be helpful if someone is coming from another compiled language such as C or Fortran or is brave enough to leave Python for some days and study the real OG.
These slides present the very basics of the language: variables definition and initialization, raw pointers, references, control flows, functions, type deduction, compile-time evaluations, error handling, and namespaces. Exercises are proposed along the way with solutions. The course makes heavy use of godbolt, a very handy online service to write, compile and execute C++ code (and much much more). Only one slide is dedicated to compilation because it was out of the lecture scope. However, an update to this material would require more details on this for those who want to start by compiling locally their code.
I am open to suggestion on possible improvements on the slides, in order to improve future courses on the topic. Especially if you find any errors (that is almost certain), feel free to report them through an issues. For now, I hope this can be helpful for someone willing to have a reference for the basic syntax or for who wants to have an introduction to C++ coming from C.
Introduction to C++
License: slides are distributed under the CC BY NC license. Please, cite all authors in the first slide and Giorgia Frumenzio (there is also another author that I cannot trace back, I’ll edit this post when I will find it out). You are free to use these slides, modifying them and disseminate them. Be aware that you cannot use them for commercial purposes and you have to distribute them with the same license.
Enjoy Reading This Article?
Here are some more articles you might like to read next: