Chapter 3 C/C ++ pointers, arrays, and strings
7th pointers
1. Pointers are addresses, that is, the addresses of the variables pointed to by the pointer.
2. a void * type pointer can be assigned a value to any type of pointer. Therefore, it cannot be used in arithmetic operations and can only be assigned, compared, or sizeof () operations.
array 7.2
1. The array name is actually the first address of the array.
2. Semantics of Delete and delete.
3. Avoid using arrays in modern c ++ Programs . Instead, use vector .
7.3 character array, character pointer, and string
1. Concept
character array: array of char element type, it may or may not contain the string end flag '\ 0 '.
string: it is also a character array and must end with the string ending sign '\ 0.
character pointer: char *, a pointer to a string. Note: The database function used to operate the string considers the character pointer to be a string containing the string end sign '\ 0.
2. Avoid using character arrays and character pointers in modern c ++ programs. Instead of string.
7.4 function pointer
1. function pointer is the address of the function. In C/C ++, the function name represents the function address. Therefore, you can assign a function name to a function pointer of the same type.
2. General function pointer
3. class member function pointer
7.5 Comparison Between Reference and pointer
remember that when I graduated to work, in the interview questions I saw on the Internet, I often had such questions. At that time, I had to answer them.
references and pointers are actually two different concepts. I can't tell the difference fluently, but it seems that I can tell the difference between them in actual use.
it is easy to misunderstand: the creation and destruction of references do not call class constructors and destructor. references are only aliases of objects (variables) and are not real objects.
the reference is mainly used to modify the form parameters and return values of a function.