2012-08-30 8 views

答えて

20

ポインタ型のエイリアスを作成するときに違いがあります。

typedef int *t1; 
#define t2 int * 

t1 a, b; /* a is 'int*' and b is 'int*' */ 
t2 c, d; /* c is 'int*' and d is 'int' */ 

また、typedef従うスコープルール、あなたがブロックにローカル・タイプを宣言することができ、すなわち。

一方、プリプロセッサーディレクティブでタイプを管理する場合は、#defineを使用できます。

関連する問題