11.17 — An introduction to std::vector

In the previous lesson, we introduced std::array, which provides the functionality of C++’s built-in fixed arrays in a safer and more usable form. Analogously, the C++ standard library provides functionality that makes working with dynamic arrays safer and easier. This functionality is named std::vector. Unlike std::array, which closely follows the …

O.3 — Bit manipulation with bitwise operators and bit masks

In the previous lesson on bitwise operators (), we discussed how the various bitwise operators apply logical operators to each bit within the operands. Now that we understand how they function, let’s take a look at how they’re more commonly used. In order to manipulate individual bits (e.g. turn them …

9.7 — Null pointers

In the previous lesson (), we covered the basics of pointers, which are objects that hold the address of another object. This address can be dereferenced using the dereference operator (*) to get the value at that address: #include <iostream> int main() { int x{ 5 }; std::cout << x; …

2.6 — Why functions are useful, and how to use them effectively

Now that we’ve covered what functions are and some of their basic capabilities, let’s take a closer look at why they’re useful. New programmers often ask, “Can’t we just put all the code inside the main function?” For simple programs, you absolutely can. However, functions provide a number of benefits …