Header defined to prevent duplicate
There are two methods, namely,
#ifndef xxx_h #define xxx_h ... #endif
#pragma once
Header files have been using the above method still multiple define
- Note that the header files only statement can not be defined, otherwise an error
- Static variable initialization method c ++ class members in private
//.h文件
class Test{
static double A;
static double B();
};
//.cpp文件
double Test::A= 2.0; //正确的静态成员初始化
vector
erase operation
- Principle: the removal process covering the back of the iter for the specified data all move forward
Note the point: the deleted position after deleting iter may become dangling pointers (if iter is the last one) so for this case to properly handle
Test code
#include <vector>
#include <cstdio>
using namespace std;
int main(){
vector <int> a;
a.clear();
a.push_back(1);
a.push_back(2);
a.push_back(3);
for(int i = 0; i < a.size(); i++)
printf("%d ", a[i]);
vector<int>::iterator itr = a.begin();
a.erase(itr+1);
for(int i = 0; i < a.size(); i++)
printf("%d ", a[i]);
}
Catch2 test framework SECTION
During a large amount of test data, SECTION enter an infinite loop state, could not get out, breakpoints can not locate the problem, after changing operating normally run directly to TEST_CASE, the problem is unknown, speculation and function related to memory limitations.