typedef 和 #define 修饰指针类型的区别

来源:互联网 发布:js保存map 编辑:程序博客网 时间:2024/05/16 02:12

typedef  和 #define 二者修饰指针类型时,作用不同。

       typedef int*  pint;       #define PINT int*       const pint p;//p不可更改,p指向的内容可以更改,相当于int * const p;       const PINT p;//p可以更改,p指向的内容不能更改,相当于 const int *p;
//或 int const *p;        pint s1, s2;  //s1和s2都是int型指针       PINT s3, s4;  //相当于int * s3,s4;只有一个是指针


 

原创粉丝点击