17.1 — Introduction to std::array

In lesson , we introduced containers and arrays. To summarize: Containers provide storage for a collection of unnamed objects (called elements). Arrays allocate their elements contiguously in memory, and allow fast, direct access to any element via subscripting. C++ has three different array types that are commonly used: std::vector, std::array, …

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 …

12.8 — 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 object 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 …