1.#define常用它来定义常量(包括无参量与带参量),属于预处理过程(编译之前),例,#define Name int;
2.typedef常用来定义一个标识符及关键字的别名,属于编译过程,实际不分配内存空间,例,typedef int Name;
3.#difine不进行类型检查,只是简单地字符替换,易出错;
typedef具有一定的封装性,不易出错;

1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 #define Name 3+3 5 6 int main() 7 { 8 int m; 9 int a=6; 10 m=Name*a; 11 cout<<m<<endl; 12 return 0; 13 14 }
结果m=21;因为: m=Name*a=3+3*6=3+18=21;
4. typedef struct Node
{
int x;
}node1,node2;
在C中,struct Node =node1=node2 ,为结构体名;
在C++中,struct Node =Node=node1=node2 ,为结构体名;
5. struct Node
{
int x;
}node1,node2;
在C中,可能编译不通过,一般用typedef;
在C++中,struct Node =Node,为结构体名;node1与node2均为Node类型的对象;
来源:https://www.cnblogs.com/qinzijing/p/5237789.html