Rico's Nerd Cluster

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

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

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.

C++ - Functions, Lambda

Lambda, Functors, Function Pointer

Functor A functor is an object that acts like a function, using the overloaded operator(). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 struct greaters{ greaters(){} operator()(int a, int b){retur...

C++ - [Templates 2] Dependent Names

Disambiguate Templates

One Example That Explains Dependent Names In C++, a name is dependent if its meaning or type, value, or definition lookup depends on, a template param T. Some examples include: std::vector<...

C++ - [Templates 1] Template Parameters

Class Templates, Dependent Name Lookup, Non-Type Template Parameters, requires, concept

Class Template Be careful with nested class inside a class template - we need to specify the template parameters here as well. 1 2 3 4 5 6 7 8 9 10 11 template <typename T> class A{ pub...

C++ - Static Functions And Keyword

Static Functions And Keyword

As a very high level summary, the keyword static has two uses: File scope static variables and functions can be only accessed within the current translation unit (i.e., the cpp source file) C...