更新时间:2022-12-24 21:21:57
声明描述了一个对象,而 definition 请求创建对象。所有定义也是声明,但事实并非如此。
A declaration describes an object, whereas a definition requests the creation of an object. All definitions are also declarations, but the reverse is not true.
对于 int a;
,具体取决于它在源代码中的位置:
In the case of int a;
, what it is depends on where it is placed in the source code:
int a;
是一个定义-它要求创建一个具有自动存储持续时间的 int
变量(并且当然也是声明); int a;
是一个临时定义(只要类型和链接都可以接受,可以有多个定义)。 ;在C ++中,它是具有外部链接的普通定义。结构
或工会$中c $ c>说明符, int a;
是成员的声明。
int a;
is a definition - it requests the creation of an int
variable with automatic storage duration (and of course also a declaration);int a;
is a tentative definition (of which there can be more than one, as long as the types and linkage are agreeable); in C++, it is an ordinary definition with external linkage.struct
or union
specifier, int a;
is a declaration of a member.