- 标识符可以被声明多次,但只能被定义一次
int a;
int a; //error:重定义
void func();
void func(); //函数声明
void func() {};
void func() {};//error:重定义
以上,int a属于变量的定义,变量的声明比如extern int a;“void func();”是函数的声明,但加上函数体就是函数的定义。
2.定义通常伴随着为标识符分配内存。
int a;
int a; //error:重定义
void func();
void func(); //函数声明
void func() {};
void func() {};//error:重定义
以上,int a属于变量的定义,变量的声明比如extern int a;“void func();”是函数的声明,但加上函数体就是函数的定义。
2.定义通常伴随着为标识符分配内存。