As the saying goes: "A good memory is worse than a bad keyboard ". I recently read 《C ++ProgramDesign tutorial. I have some insights on the differences between the function prototype and the function definition in the function call. I will record it and study it later.
When defining a function, the program pushes the parameters to be passed into the stack. The specific parameter sequence is related to the compiler. Then Call The address of the called function. Sometimes the program passes compilation during compilation, and the connection becomes faulty, prompting that the function body cannot be found, Vc6.0 Tip: Unresolved externals This is sometimes caused by inconsistent function definitions with function declarations. Why can't I connect through compilation? This involves the compilation process. During compilation, it usually checks whether the syntax is correct and whether the function is called in accordance with the call specifications. How can we ensure the call specifications? Is through the function prototype. The compiler searches for all function prototypes to see if there are any declarations that match the function call form. If yes, the compiler compiles the statements. As for the specific content of the function definition, the compiler only performs regular syntax checks. It is estimated that the compilation is carried out in function segments and is finally connected. Therefore, an error will be reported during the connection, indicating that the connection cannot be found.
Another function prototype is different in definition. If you want to add the default parameters of a function, you must add them to the function declaration. Instead, you cannot add them to the Function Definition and add them to the function declaration, the compiler will push the parameters into the stack in advance. If the parameter is placed in the definition, compilation will fail, if both the prototype and definition have default parameters, the default parameters are repeatedly defined ~~~ It may be that pressure is not allowed. 2 next stack), only default parameters are defined, when a function is called without parameters, because the parameters called during compilation are checked by the function prototype, compilation is not supported.