1. typedef int size_t;
Most books and teachers will talk about this statement. This is the alias for defining size_t as an int. That is, typedef a B. B is the alias of.
The result is correct, but it is not necessarily correct in terms of grammar. It cannot be understood as follows:
2. typedef int int_array [4];
Int_array A, B;
If you understand this, see:
3. typedef int (* PF) (const char *, const char *);
PF register (PF );
If you understand this, the following content is not prepared for you. If you do not understand, please refer to: (here I will try to explain it as much as possible)
If you think the following statement is troublesome:
Int A [4], B [4], C [4];
You want to simplify or hide complex types through the following statement:
Int_array A, B, C;
The method to use typdef is as follows:
1. Find the generic format you want to declare. For example, int A [4], B [4], C [4]; only A, B, and C are different, they have the same declarative mode int <Name> [4];
2. Use the new type name you want to declare to replace the change section in the general format. For example, the position of A, B, and C is replaced by the new type int_array, And the typedef symbol is added to the front, that is:
Typedef int int_array [4];
3. When you want to declare the, B, and C Types in the int_array position above, you can use the following statement:
Int_array A, B, C;
Simply put, in a defined typedef <string>;, an undefined type name type_a appears in the <string>. When you use this typedef:
The meaning of type_a object is that you actually declare to replace type_a in <string> with the object name.
For example, typedef int int_array [4];
Int_array object;
In fact, the statement you wrote is: Replace the string "int int_array [4];" with the int_array in the object to get the result: int object [4];
This is how the compiler processes the tyepdef definition.
After this explanation, you should easily understand the function pointer typedef. Is it very simple!
If you have read the original article, please leave a message in your reply ^_^