5.x — Chapter 5 summary and quiz
Chapter Review A constant is a value that may not be changed during the program’s execution. C++ supports two types of constants: named constants, and literals. A named constant is a constant value...
View Article5.3 — Constexpr variables
The constexpr keyword When you declare a const variable using the const keyword, the compiler will implicitly keep track of whether it’s a runtime or compile-time constant. In most cases, this doesn’t...
View Article9.x — Chapter 9 summary and quiz
Chapter Review Scope creep occurs when a project’s capabilities grow beyond what was originally intended at the start of the project or project phase. Software verification is the process of testing...
View Article8.15 — Global random numbers (Random.h)
What happens if we want to use a random number generator in multiple functions or files? One way is to create (and seed) our PRNG in our main() function, and then pass it everywhere we need it. But...
View Article11.x — Chapter 11 summary and quiz
Nice work. Function templates may seem pretty complex, but they are a very powerful way to make your code work with objects of different types. We’ll see a lot more template stuff in future chapters,...
View Article16.5 — Returning std::vector, and an introduction to move semantics
When we need to pass a std::vector to a function, we pass it by (const) reference so that we do not make an expensive copy of the array data. Therefore, you will probably be surprised to find that it...
View ArticleB.5 — Introduction to C++23
What is C++23? In February of 2023, the ISO (International Organization for Standardization) approved a new version of C++, called C++23. New improvements in C++23 For your interest, here’s a list of...
View Article12.15 — std::optional
In lesson 9.4 -- Detecting and handling errors, we discussed cases where a function encounters an error that it cannot reasonably handle itself. For example, consider a function that calculates and...
View Article13.4 — Converting an enumeration to and from a string
In the prior lesson (13.3 -- Unscoped enumerator integral conversions), we showed an example like this: #include <iostream> enum Color { black, // 0 red, // 1 blue, // 2 }; int main() { Color...
View Article13.5 — Introduction to overloading the I/O operators
In the prior lesson (13.4 -- Converting an enumeration to and from a string), we showed this example, where we used a function to convert an enumeration into an equivalent string: #include...
View Article
More Pages to Explore .....