In-Depth Analysis of RAII: The Cornerstone of Modern C++ Resource Management

In-Depth Analysis of RAII: The Cornerstone of Modern C++ Resource Management

0. Introduction In C++ development, there is an unavoidable topic—resource management. Whether it is memory, file handles, or network connections, these are resources that need to be reclaimed. If not handled properly, it can easily lead to memory leaks and resource exhaustion. RAII, as the cornerstone of modern C++ resource management, has transformed the cumbersome … Read more

The ‘Invisible’ Philosophy of C++ Design Patterns: Beyond Singleton, Where Else Do We Use Them?

The 'Invisible' Philosophy of C++ Design Patterns: Beyond Singleton, Where Else Do We Use Them?

Click the blue text to follow the author 1. The ‘Invisible’ Mystery of C++ Design Patterns Have you ever thought: apart from the ubiquitous Singleton pattern in daily C++ code, the ‘standard’ implementations of other patterns rarely appear. 1.1. Why Do We Only See Singleton? Design patterns, especially the 23 classic patterns proposed by the … Read more

Understanding Guard and Deref in Rust

Guard <span>Guard</span> is a common concept in Rust, meaning “to guard”. What does it guard? It guards resources, data, etc., within a specific scope. For example, the guards for mutexes and read-write locks are: • <span>MutexGuard</span> • <span>RwLockReadGuard</span> and <span>RwLockWriteGuard</span> They are an implementation of RAII (Resource Acquisition Is Initialization), a resource management technique from … Read more

RAII: More Than Just Memory Management – Unlocking the Ultimate Weapon of C++ Core Design Patterns

Did you think RAII is just for managing memory? That might only unleash 1% of its power. 1. Reassessing RAII: From “Tool” to “Philosophy” When it comes to RAII, almost every C++ programmer can immediately recite: “Resource Acquisition Is Initialization”. Our first reaction is to think of smart pointers: <span>std::unique_ptr</span>, <span>std::shared_ptr</span>. Indeed, they are one … Read more

Summary of C++ Interview Questions from Major Companies in 2025

Content from Programmer Lao Liao: https://space.bilibili.com/3494351095204205 1.Please explain which memory area each variable in the following code is stored in and why.【Tencent – Backend Development】 #include <iostream>const int g_const = 10; // Constant areaint g_var = 20; // .data sectionstatic int s_var = 30; // .data sectionchar* p_str = "Hello"; // p_str in .data section, … Read more

C++ Rule of Zero: The Evolution from Rule of Three to Rule of Zero

Resource Management and Ownership In C++, the destructor of an object with automatic storage duration is called when its scope ends. This feature is often used to implement the RAII (Resource Acquisition Is Initialization) pattern to automatically handle resource cleanup. The core of RAII is the concept of resource ownership: an object responsible for cleaning … Read more

C++ Smart Pointers: Types, Usage, and Practices

C++ Smart Pointers: Types, Usage, and Practices

In today’s article, we will revisit smart pointers in C++. In resource management in C++, manually using <span>new</span>/<span>delete</span> can easily lead to memory leaks, dangling pointers, and exception safety issues. The smart pointers introduced in C++11 encapsulate ordinary pointers with RAII (Resource Acquisition Is Initialization): automatically releasing resources when the object goes out of scope, … Read more

Interview Experience for C++ Development at Insta360

Interview Experience for C++ Development at Insta360

First Interview 1. Interviewer Self-Introduction 2. Self-Introduction Reference Answer 30–60 seconds “four-part format”: Background → Tech Stack → Representative Projects → Quantified Results; 3. Memory Layout of Classes Reference Answer No virtual functions: Object = Order of data members + Alignment padding; when containing a base class, the “base class sub-object” is at the front. … Read more

In-Depth Analysis of C++ Syntax and Core Interview Insights

In-Depth Analysis of C++ Syntax and Core Interview Insights

Content from: Programmer Lao Liao https://space.bilibili.com/3494351095204205 Chapter 1: C++ Memory Model and Object Lifecycle 1.1 Memory Segmentation: Stack, Heap, Global/Static Storage Area, Constant Area The memory layout of a C++ program is typically divided into several areas, understanding them is crucial for writing efficient and safe code. Stack Stored Content: Local variables, function parameters, return … Read more

A Review of C++ Smart Pointers: Types, Usage, and Practical Scenarios

A Review of C++ Smart Pointers: Types, Usage, and Practical Scenarios

👆Click the blue text "Linux Armory" at the top, and select "Add to Favorites" in the upper right corner to not miss out on great articles and see valuable content first. 👆FollowLinux Armory, to receive hardcore Linux learning materials and code. Today, let’s revisit smart pointers in C++. In C++ resource management, manually using <span>new</span>/<span>delete</span> … Read more