编译器是怎么判断是定义还是声明的

2017-03-31  本文已影响14人  HenryTien

Declarations introduce names in a program, for example the names of variables, namespaces, functions and classes. Declarations also specify type information as well as other characteristics of the object that is being declared. A name must be declared before it can be used; in C++ the point at which a name is declared determines whether it is visible to the compiler. You cannot refer to a function or class that is declared at some later point in the compilation unit; you can use forward declarations to get around this limitation.
Definitions specify what code or data the name describes. The compiler needs the definition in order to allocate storage space for the thing that is being declared.

C++中声明和定义的区别

上一篇 下一篇

猜你喜欢

热点阅读