Random Link ¯\_(ツ)_/¯ | ||
Jun 4, 2022 | » | Enumerations in C++
7 min; updated Jun 4, 2022
Unscoped (or Plain or C-Style) Enumerations Plain (or C-style) enums are entered in the same scope as the name of their enum, and implicitly convert to their integer value, e.g. enum Color { red, green, blue }; int col = green; Color c2 = 1; // error: invalid conversion from 'int' to 'Color' [-fpermissive] enum CardColor { red, black }; // Error: "red" conflicts with a previous declaration... |
Jun 4, 2022 | » | User-Defined Types
(4 items)
Classes in C++; Structures in C++; Enumerations in C++; Unions in C++; |
May 30, 2022 | » | Templates in C++
4 min; updated May 30, 2022
A template is a class or a function that we can parameterize with a set of types or values. Parameterized Types The vector-of-doubles can be generalized to a vector-of-anything type by making it a template: // `template<typename T>` can be read as "for all types T". Older code // uses `template<class T>`, which is equivalent. template<typename T> class Vector { public: explicit Vector(int s); ~Vector() { delete[] elem; } // .... |
May 12, 2022 | » | Classes in C++
15 min; updated May 12, 2022
quotes Doug McIlroy: Those types are not “abstract”; they are as real as int and float. What is the context of this quote? A class is a user-defined type provided to represent a concept in the code of a program. Essentially, all language facilities beyond the fundamental types, operators, and statements exist to help define better class or to use them more conveniently.... |
Mar 16, 2022 | » | AoC 2021 Day 09: Smoke Basin
13 min; updated Mar 16, 2022
Multi-dimensional arrays using |