Home > Back-end >  Of new inquire about the function declaration
Of new inquire about the function declaration

Time:10-06

Why can not define the parameters in the function declaration, and to talk about this topic? Thank you!

CodePudding user response:

Obviously is D, D is the function implementation, have the function body (the content of the {}, even if is an empty function body, also have the function body),
Function does not necessarily have parameters, the parameters of the prototype so it is empty or void, so there is nothing wrong with A

CodePudding user response:

D has no return value, so wrong,

CodePudding user response:

Prototype is refers to the statement, without {}
With {} is defined,

CodePudding user response:

reference 1st floor qybao response:
is clearly D, D is the function implementation, have the function body (the content of the {}, even if is an empty function body, also have the function body),
Function does not necessarily have parameters, the parameters of the prototype so it is empty or void, so there is nothing wrong with A

Ok thank you thank you!

CodePudding user response:

Function declaration, if there is no parameter, suggest using void, also can not write, but still suggest writing void;

D option is obviously a function definition, rather than statement, the statement of the function is no curly braces, and have a semicolon,
  • Related