Thinking answer question

Source: the suffix .c file
header file: the file suffix .h the
question: Can the declaration of a function and a variable in the source file?
I think it could function and variable declarations in the source file inside, which is equivalent to the usual in header files inside invisible code to play out, such as function declarations in the source file is equivalent to the function play out of it. And we usually have their own defined function and then finished at the top of the statement.
Question two: Can-defined functions and variables in header files?
I think it could function and variable definitions in header files, and I feel on top of the header file is not essentially different from the above source file with it, so the first document which can also be defined functions and variables.
Question three: the same can not declare a function or variable in both the first document?
I think if the two heads so it does not refer to a file in the same source file which it should be able to declare a function or variable with it, but if you reference the same time inside the same source file, the phenomenon will repeat defined, time should not.
I have found to say different scopes contain can be resolved in two header files define the same name as the class and repeat the definition of the problem should be used in a source file inside, but I see also unclear o (╥﹏╥) o. Here is the URL https://blog.csdn.net/u012411498/article/details/80831444
Question 4: Can you define the same function or variable in the two source files?
I think if these two are not connected with the source file that can be defined with a function or variable, but if they are separate modules linked together later, it is a phenomenon that should have duplicate definitions occur, the system does not I know who to listen to, this time should be no.
Checked, it is said to use static definition of variables, such other documents will not use static variables to this document, will not be repeated error defined.

Guess you like

Origin www.cnblogs.com/2002ljy/p/12227361.html