您的位置:首页 > 其它

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

2013-08-06 22:55 155 查看
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;只有一个是指针


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  typedef #define 区别