c/c++ pointers #2

Table of Contents Table of Contents 1: Arrays and pointers 1.1: Understanding array names 1.2: Using pointers to access arrays 1.3: The essence of array parameter passing 2: Secondary pointer 3: Pointer array 4: Array pointer 5: Character pointer 6: Function pointer 7: Array of function pointers 1: Array and pointer Definition: Pointer variables are […]

The use of C++ smart pointers: the use of shared_ptr, weak_ptr, unique_ptr, use case description.

Directory of series articles Contents of this chapter: (1) Introduction to shared_ptr, weak_ptr, unique_ptr (2) Memory leak caused by using share_ptr alone (3) Combined use of shared_ptr and weak_ptr Article directory Table of Contents of Series Articles Preface 1. Use of shared_ptr, weak_ptr, unique_ptr 1.1 shared_ptr 1.2 weak_ptr 1. Creation of weak_ptr pointer 2. Member […]

Base class pointers, derived class pointers and virtual functions in C++ inheritance

In C++, Inheritance is one of the core ideas of object-oriented programming. It builds a hierarchical relationship between classes, with the concepts of parent classes and subclasses. This article will summarize the relevant content of base class pointers, derived class pointers and virtual functions, and attach corresponding sample codes. 1. Base class pointer, derived class […]

[C Language] Debugging questionable function pointers and writing callback functions (Callback function parameters in the structure and false callback function __weak declaration)

[C Language] Debugging questionable function pointers and writing callback functions (Callback function parameters in the structure and false callback function __weak declaration) Article directory Debugging questionable function pointers function pointer function call Writing callback function callback function inside the structure fake callback function Appendix: Compressed strings, big and small endian format conversion Compressed string floating […]

Structures and structure pointers in C language

1. Definition, reference and initialization of structure Sometimes it is necessary to combine different types of data into a whole for easier reference. For example, a student has attributes such as student number, name, gender, age, address, etc. If a separate variable is defined for the student’s student number, name, age, etc., then it will […]

Tormented by pointers (3)

1. Character pointer variable We know that character pointers are pointers that store characters, so can character pointers store strings? let’s take a look #define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() {<!– –> char* p = “asdfghjkl”; printf(“%c\\ “, *p); return 0; } Will it output a string? As you can see, the string cannot […]

c++ series – smart pointers

1. The use and principle of smart pointers 1.1 RAII RAII (Resource Acquisition Is Initialization) is a simple technology that uses the object life cycle to control program resources (such as memory, file handles, network connections, mutexes, etc.). Acquire resources when the object is constructed, then control access to the resources so that they remain […]

“The Third Level of Algorithm Clearance Village – The Magical Use of Double Pointers”

Directory: Understand how the double pointer idea works (fast and slow type and collision type) Understand how double pointers solve the problem of deleting elements Understand how dual pointers solve the odd-even movement problem Understand how double pointers solve array rotation problems Understand how pointers solve interval-related problems Understand how double pointers solve string substitution […]