C++笔记

1. Initialize the list scheme

When defining a variable, curly braces such as: int a{};

2. Reference (give an alias to an existing variable)

int a=10;

int =b=3;

int &c=a;

c is equal to a , and does not open a space for c independently, but uses a reference method, so that c and a are called different names, but in fact they are exactly the same

3. Write interchange functions with references

//利用引用交换两个数
void swap(int& x, int& y) {
	int t = x;
	x = y;
	y = t;
}

4. Write swap functions using citations

References must reference variables that have already been defined, but frequent references can directly define values such as:

const int &x=100;

Bottom layer: const int *p=tmp;

tmp=100;

int & const q=x             ----->等于            int & q=x

你可能感兴趣的:(c++,开发语言)