1. What is a memory leak
2. How to avoid memory leakage
3. Why is there a smart pointer
4. Use and principle of intelligent pointer
4.2 classes designed with RAII idea
4.3 implementation of intelligent pointer
1. What is a memory leak
1. Memory leak: memory leak refers to the situation th ...
Posted by kjelle392 on Sat, 05 Mar 2022 16:50:49 +0100
Original address: https://developers.google.com/protocol-buffers/docs/cpptutorial
This article briefly introduces how to use protocol buffer in C + + through an example. You can learn:
How to work in the The message format is defined in the proto file;How to use the protocol buffer compiler;How to use the C++ protocol buffer interface to re ...
Posted by g00bster on Sat, 05 Mar 2022 15:55:55 +0100
Top ten sorting algorithms
Common sorting algorithms include bubble sort, selection sort, insertion sort, merge sort, quick sort, Hill sort, heap sort, count sort, bucket sort and cardinal sort
When adjacent elements are equal, they do not exchange positions, so bubble sorting is a stable sorting.
void bubbleSort(vector ...
Posted by anujgarg on Sat, 05 Mar 2022 15:10:00 +0100
With the foundation of the red and black trees in front, our task in this section is relatively easy.
Let's explain what Map and Set are with the help of network literature.
First of all, we need to know that the bottom layers of Map and Set are red and black trees.
It is a balanced binary search tree, that is, binary balanced search tree.
Posted by astricks on Sat, 05 Mar 2022 14:30:08 +0100
Five memory areas of C + +
The memory pattern of C + + programs is usually divided into five areas: global data area, code area, stack area, heap area (i.e. free storage area) and constant area.Global data area (static area): store global variables, static data and constants;Code area: store the codes of all class member functions and non memb ...
Posted by The.Pr0fess0r on Sat, 05 Mar 2022 13:53:58 +0100
How does the Reader read the data of the Writer (top-level logic)
Generally, the reader is created with a Node. For example, in the Component class (the Component can process up to four message types at the same time. Here we will choose one data type to explain):
reader = node_->CreateReader<M0>(reader_cfg)
Therefore, we ca ...
Posted by ben2005 on Sat, 05 Mar 2022 12:39:47 +0100
std::vector source code analysis
Observe the STL design from the perspective of source code, and the code is implemented as libstdc++(GCC 4.8.5)
Because we only focus on the implementation of vector, and the implementation of vector is almost all in the header file, we can use such a method to obtain relatively fresh source code
Create a process and directly call the fork function:
Negative value: failed to create child process. 0: return to the newly created child process. Positive: returns to the father or caller. This value contains the process ID of the newly created child process.
Posted by nac20 on Sat, 05 Mar 2022 09:34:12 +0100
The so-called variable parameter means that the number and type of parameters can be arbitrary.
For function parameters, C + + always supports setting variable parameters for functions. The most typical representative is the printf() function. Its syntax format is:
int printf ( const cha ...
Posted by malcolmboston on Sat, 05 Mar 2022 07:55:00 +0100
1002 write this number
c + + number and string conversion
Method 1: use stringstream: add header file #include
Number to string #include <string>
double a = 123.32;
stringstream ss; //Define stream ss
ss << a; //Convert number a to stream ...
Posted by neverett on Sat, 05 Mar 2022 06:14:38 +0100