c++webserver/Chapter III Linux Thread Development
1. Threads
1. Definition
Similar to a process, threads are a mechanism that allows applications to perform multiple tasks concurrently. ** A process can contain multiple threads. ** All threads in the same program execute the same program independently and share the same global memory area, including initialized, uninitialized, and hea ...
Added by sheila on Mon, 21 Feb 2022 19:22:04 +0200
C++ Custom String Class
It is quite complex to implement advanced String classes. Unlike C++ and C#, many modules need to solve their own memory problems, and how to improve the efficiency of memory space, whether calling a function triggers a copy constructor, and how to avoid duplicate memory release when triggering a copy constructor.
There are a few overloads ...
Added by Gladiator2043 on Mon, 21 Feb 2022 19:16:22 +0200
week02 project 3-input optimization
preface
This article mainly introduces the concepts of string and array in C/C + +
1. String storage variable
1.1 project requirements
On the basis of item 2, the user name and password are stored in strings
1.2 project realization
login2.cpp
#include <iostream>
#include <Windows.h>
#Include < string > / / St ...
Added by pontiac007 on Mon, 21 Feb 2022 16:07:33 +0200
First knowledge of branch statements
What is a branch statement before understanding it?
Statement: a statement separated by a semicolon in C language, such as printf("hehe");
1, if else branch statement
The following code
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int age =10;//Branch statements execute only one sentence by default
if ...
Added by jlarson on Mon, 21 Feb 2022 13:09:04 +0200
[3] Object oriented programming: operator overloading and temporary objects
Section 5 operators and operator overloading
In C + +, the operator itself is a function that can be customized by users. Then we think that the calculation of complex numbers is not as good as using the + sign directly, and the concept and operation rules of the + sign need operator overloading.
Operator overloading can be written in two way ...
Added by srdva59 on Mon, 21 Feb 2022 13:03:14 +0200
muduo library net source code analysis III (timer)
Enables EventLoop to handle timer events
Timing function
Used to make the program wait for a period of time or schedule a scheduled task:
sleep
alarm usleep
nanosleep
clock_nanosleep
getitimer / setitimer
timer_create / timer_settime / timer_gettime / timer_delete
timerfd_create / timerfd_gettime / timerfd_settime chooses this method. ...
Added by Ixplodestuff8 on Mon, 21 Feb 2022 08:34:16 +0200
Template of C + + foundation
Generic Programming
When learning function overloading before, we wrote a Swap function Swap
void Swap(int& left, int& right)
{
int tmp = left;
left = right;
right = tmp;
}
void Swap(char& left, char& right)
{
char tmp = left;
left = right;
right = tmp;
}
void Swap(double& left, double& right)
{
double tmp ...
Added by 6pandn21 on Mon, 21 Feb 2022 07:29:58 +0200
C + + Performance Optimization -- memory pool technology
1, Memory pool introduction
1. Introduction to C + + memory pool
Memory pool is a kind of memory allocation method. It is to apply for allocating a certain number of memory blocks of equal size (generally) for standby before using memory. When there is a new memory demand, a part of the memory block is separated from the memory pool. If the m ...
Added by Majes on Mon, 21 Feb 2022 04:26:00 +0200
7-1: IO stream of C + +
1: Input and output of C language and C++ IO stream
In C language, there are three groups of input and output functions that we often use
Input / outputOperation objectprintf/scanfConsolefprintf/fscanffilesprintf/sscanfCharacter array (buffer)
The corresponding operations in C + + are as follows
Input / outputOperation objectostream/isr ...
Added by spramod on Sun, 20 Feb 2022 19:37:03 +0200
C + + memory management
compare some differences between C and C + + definition categories to
Stack as an example:
C language defines the stack is nothing more than defining a structure and then defining some functions. Its data and functions are separated. When operating data, you need to call the initialization function after defining the t ...
Added by venradio on Sun, 20 Feb 2022 18:48:37 +0200