13.13 — Class templates

In lesson , we introduced the challenge of having to create a separate (overloaded) function for each different set of types we want to work with: #include <iostream> // function to calculate the greater of two int values int max(int x, int y) { return (x < y) ? y …

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 . A using-directive allows all of the identifiers from a given namespace to …

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 …