1) #define是preprocessing Directives, which is performed when the preprocessing is compiledsimple substitution, no correctness check, whether the meaning is correct or not, only when compiling the source program has been expanded to find possible errors and error.
For example: #define PI 3.1415926 Program: Area=pi*r*r will be replaced with 3.1415926*r*r if you write the number 9 in the # define statement as the letter G preprocessing is also brought in. 2) A typedef is processed at compile time.
It gives an alias to an already existing type within its scope, but you cannot use the typedef specifier inside a function definition.
3) typedef int * INT_PTR; As with #define INT_PTR int *, the function is to use INT_PTR to represent int *, but they are different, as mentioned earlier, a simple substitution #define在预处理, whereas a typedef is not a simple substitution, but rather a type declared as a method of defining a variable.
That is #define INT_PTR int * Int_ptr A, B; equivalent to int * A, B;
Just a simple macro replacement typedef int* INT_PTR; INT_PTR A, B;
A, B is a pointer to int, and TypeDef introduces a new mnemonic for int*. This also explains why the following view is set up//qunkangli (maintenance cost proportional to the square of Programmer's Creativity) typedef int * PINT;
#define PINT int * Then: the const PINT p;//p cannot be changed, but the contents of P point can change the const PINT p;//p can be changed, but the contents of P point cannot be changed.
Pint is a pointer-type const pint P is to lock the pointer to P cannot be changed and the const pint p is a const int * p Lock is the object that the pointer p refers to.
3) Perhaps you have noticed that # define is not a statement do not add a semicolon at the end of the line, or a semicolon is replaced. Reprint Http://zhidao.baidu.com/link?url=
Jr1uch9jjksz1mzioxnvk3l53u66lqey6wdztcvxaxi6mbpkg7owrv6hg6iwihzuqeyoawxim8rr1sgd_c46rq