Use of C++ STL list

C++ list usage   general Defined in the header file < list >, std::list is a container that supports constant time to insert and remove elements from any location of the container. Fast random access is not supported. It is usually implemented as a two-way linked list. With STD:: forward_ Compared with list, this container prov ...

Added by J4rod on Tue, 08 Feb 2022 07:00:24 +0200

Name masking in C + + inheritance

Name masking in C + + inheritance If the members in the derived class (including member variables and member functions) have the same name as the members in the base class, the members inherited from the base class will be masked. The so-called masking means that when using this member in a derived class (including when defining a derived clas ...

Added by serial on Tue, 08 Feb 2022 04:53:38 +0200

AB + + enumeration and Acwing + + simulation class 4

Examples AcWing 1210. Consecutive interval number Xiao Ming has been thinking about such a strange and interesting question these days: How many consecutive intervals are there in an arrangement of 1 ∼ N? The definition of the serial interval here is: If all the elements in the interval [L,R] (i.e. the L-th to r-th elements of this ar ...

Added by fiona on Mon, 07 Feb 2022 21:46:51 +0200

PAT class B 1073 problem solving

Title details: Common scoring method for 1073 multiple choice questions (20 points) Correcting multiple-choice questions is a troublesome thing. There are many different scoring methods. One of the most common scoring methods is: if the examinee selects some correct options and does not select any wrong options, he will get a 50% score; If a c ...

Added by aneesme on Mon, 07 Feb 2022 12:28:24 +0200

C + + relearning -- vector container

vector container concept Very similar to arraysvector can be extended dynamically, but array cannotPoints to a contiguous piece of memoryDynamic expansion is to find a new and larger space to store data, rather than adding a new space behind it Iterator failure: when the vector finds a new and larger space, the previous iterator fails struc ...

Added by lovelys on Mon, 07 Feb 2022 11:39:07 +0200

Ant colony algorithm to solve 0-1 knapsack problem

Experimental report on 0-1 knapsack problem realized by ant colony algorithm [experiment content] The 0-1 knapsack problem is solved by ant colony algorithm. [experimental environment] Microsoft Visual C++ 6.0 [basic theory] Ant colony algorithm is a bionic algorithm based on the simulation of the foraging and path finding methods o ...

Added by vbcoach on Mon, 07 Feb 2022 04:22:28 +0200

C + + -- classes and objects

Class declaration Class is the keyword that defines the class, ClassName is the class name, and {} is the body of the class. Note that the semicolon is followed at the end of class definition. class ClassName{ //The body of a class is composed of member functions and member variables }; Class members include: Member variableMember f ...

Added by supinum on Sun, 06 Feb 2022 23:16:46 +0200

c + + operator overloading ------------- 1 plus operator overloading

1 plus operator overload: 1.1 / / member function implementation + operator overload Implementation statement: Person operator+( Person& p)//Pass in a new parameter and add it to the previous one. {//There is no calling relationship. Implicit relationship. Person temp; temp.m_A = this->m_A + p.m_A; temp.m_B = this->m_B + p.m_B; ...

Added by s3rg1o on Sun, 06 Feb 2022 22:41:51 +0200

Data structure learning, binary tree

catalogue Header file and macro definition to be referenced in advance Other data structures needed (chain stack and chain queue) The structure of the binary tree used (binary linked list) Its basic operation interface basic operation Create an empty binary tree Create a binary tree, where the value of the root node is e, and L and R ar ...

Added by fred_belanger on Sun, 06 Feb 2022 22:12:55 +0200

Function overloading from several examples

Several commonly used functions #include <iostream> void func(int a){ std::cout << "global func: " << a << std::endl; } namespace test{ void func(int a){ std::cout << "namespace test func: " << a << std::endl; } }; class Demo { public: void func(int a){ ...

Added by RottenBananas on Sun, 06 Feb 2022 21:44:49 +0200