Study on the departure of the C + + expedition
1. References
Base type reference: int a = 3; int &b = A;
struct type reference: typedef struct {int x; int y;} Coor;
Coor C1; Coor &c = C1; c.x = 10; C.y = 20; cout << c1.x << c1.y;
Pointer type reference: int a = 10; int *p = &a; int *&q = p; *q = 20; cout << a << Endl;
Function Reference: Fun (int &a, int &b) {}
int x = ten, int y = 20;
Fun (x, y)
2. Const
Base type: const int a = 10; A is a constant
Pointer: const int *p = NULL; int const *P = NULL; Equivalent
int * Const P = NULL;
const INT * Const P = NULL; int const * Const p = NULL; Equivalent
Reference: int x = 10; const int &y = x; x = 20; correct//y = 20; error
3. Function characteristics
Default value, function overload (function with the same name), inline function
4. Memory Management
Application: new,new *p = new int; New *arr = new INT[10]; block memory request and release. Application to determine whether it is empty (empty is wrong)
Release: Delete,delete p; delete []arr; Release to set a null pointer
C + + Start learning 2