A.4 — C++ FAQ

There are certain questions that tend to get asked over and over. This FAQ will attempt to answer the most common ones. Q1: Why shouldn’t we use “using namespace std”? The statement using namespace std; is a . Using directives import all of the identifiers from a namespace into the …

5.8 — Constexpr and consteval functions

In lesson , we introduced the constexpr keyword, which we used to create compile-time (symbolic) constants. We also introduced constant expressions, which are expressions that can be evaluated at compile-time rather than runtime. Consider the following program, which uses two constexpr variables: #include <iostream> int main() { constexpr int x{ …

8.13 — Introduction to random number generation

The ability to generate random numbers can be useful in certain kinds of programs, particularly in games, statistical modelling programs, and cryptographic applications that need to encrypt and decrypt things. Take games for example — without random events, monsters would always attack you the same way, you’d always find the …