What is the significance of forward declaration in C programming?

后端 未结 4 1842
长情又很酷
长情又很酷 2021-01-04 18:57

I am now learning C programming through Learn C the Hard Way by Zed A. Shaw. There is this code (taking from his website):

#include 
#include          


        
4条回答
  •  佛祖请我去吃肉
    2021-01-04 19:33

    Forward declaration is upto the program's need. Programmer can design it in their own.

    Understand the significance: In C and C++, the line above represents a forward declaration of a function and is the function's prototype. After processing this declaration, the compiler would allow the program code to refer to the entity printThisInteger in the rest of the program. The definition for a function must be provided somewhere (same file or other, where it would be the responsibility of the linker to correctly match references to a particular function in one or several object files with the definition, which must be unique, in another):

提交回复
热议问题