Intro
Intro#
In this part, we will introduce the aspects of C++ that we’ll encounter in this course. Our approach will be learning by doing — we’ll mostly look at short, commented examples that you can (should!) try for yourself.
Beyond this course page, there are approximately one gazillion online resources for learning C++. We encourage you to explore at least some of them!
Since many that follow this course will have experince with Python, we will often contrast and compare C++ to Python.
Before we jump in, here are some C++ facts you should know:
In contrast to e.g. Python programs, C++ programs must be compiled and linked before they can be run. This is done using a tool called a compiler.
Compared to Python, C++ is much stricter when it comes to variable types.
The C++ language is based on the older C language. (C is effectively a subset of C++.) This means that C code will also work in C++ programs. But for our examples, we will try to stick to C++-style code.
C++ is a very rich and powerful language. The drawback is that it can seem a bit complicated to begin with. But by mastering it, you probably also gain a deeper understanding of programming than you get from only using Python.
Like other programming languages, C++ is evolving, with new features being added to the language for every new “version” (standard) of the language. In our code examples, we will follow the “C++11” standard. (The most common standards are C++98, C++03, C++11, C++14, C++17, C++20.)
Now, let’s look at some code!