Rico's Nerd Cluster

「离开世界之前 一切都是过程」

C++ - Iterators

Basic Usage An iterator needs to be dereferenced *it or it->first so its internal data can be accessed. Iterator Category Examples Supported Operations ...

C++ - [OOP] Members

Member Attributes and Methods, Copy, Move, Static Members

Member Attributes Let’s take a look at a tricky example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include <iostream>...

C++ - [OOP] Polymorphism Substitute - Curiously Recurring Template Pattern (CRTP)

static polymorphism

Optimization Impact: ⭐️⭐️⚪⚪⚪ CRTP is a design pattern where the base class takes in derived class as a template parameter. This way, no virtual function is created, no runtime cost is spent on vta...

C++ - [OOP] Polymorphism - Virtual Functions and Virtual Inheritance

Virtual is virtually complicated. Dynamic Dispatch, Dreadful Diamond Derivative (DDD) Problem ...

Introduction The virutal keyword is very versatile. A really short and nasty summary is, it is to ensure the correct functions or base class is inherited / loaded during runtime. Motivating Examp...

C++ - [OOP] Initialization 2 - Ordering

Default Initialization, Memory Order, Ctor for Inheritance, Parsing and Construction

Default Initialization Default Initialization is when a variable is initialized without explicit value. They could be in an uninitialized state and accessing them could be an undefined behavior. ...

C++ - [OOP] Destruction

Destruction Ordering

The destruction order is Derived Class -> Derived class members -> base class, which is the inverse order of construction: base class -> Derived class members -> Derived Class 1 2 3 4 ...

C++ - [OOP] Initialization 1 - Construction Basics

Conversion, Assignment, Copy

Constructor And Assignment When an new object is created, it’s either: Constructed from scratch Or copied from another object. The object could be temporary or permanent. Conversion and Ex...

C++ - Friends

Friend Class, Friend Function, Inner Class, Forward Declaration

In C++, friend functions and friend classes provide controlled access to private members of a class. While useful, they should be used judiciously to maintain encapsulation and avoid unnecessary de...

C++ - Language Properties

Zero-Overhead Abstraction, Garbage-Collection-Free, Endianness Handling, One-Definition-Rule (ODR)

C++ and C are known for their high performance. High level languages like Python are known for their relative ease of use. In this article, we will compare the two sides and see what makes C++ spec...

C++ - Coding Styles

Casing

Casing namespace: lower case like std, boost.