21.3 — Overloading operators using normal functions

In the previous lesson, we overloaded operator+ as a friend function: #include <iostream> class Cents { private: int m_cents{}; public: Cents(int cents) : m_cents{ cents } {} // add Cents + Cents using a friend function friend Cents operator+(const Cents& c1, const Cents& c2); int getCents() const { return m_cents; …

2.12 — Header guards

In lesson , we noted that a variable or function identifier can only have one definition (the one definition rule). Thus, a program that defines a variable identifier more than once will cause a compile error: int main() { int x; // this is a definition for variable x int …

16.2 — Introduction to std::vector and list constructors

In the previous lesson , we introduced both containers and arrays. In this lesson, we’ll introduce the array type that we’ll be focused on for the rest of the chapter: std::vector. We’ll also solve one part of the scalability challenge we introduced last lesson. Introduction to std::vector std::vector is one …