0

WHAT IS FUNCTION PROTOTYPE

Explain it as you are explaining it to a 7 year boy

7th Mar 2018, 4:59 PM
Priyam Sharma
Priyam Sharma - avatar
2 Answers
+ 6
What they both failed to mention is the parameter names are optional so: int maximum(int,int); int add(int,int); would be fine. The names are usually included to document what the function is expecting to receive for those arguments.
7th Mar 2018, 5:17 PM
John Wells
John Wells - avatar
+ 1
This is the function definition without the body. It is used in #include files so the compiler can make sure you use the correct argument types when calling the function. Example function prototype: int maximum(int a, int b) ; The full function: int maximum(int a, int b) { return (a > b)? a : b; } The function body is usually compiled separately either as part of a library or as a different part of your project while the prototype line appear in an #include file (.h file) that every other file thst wishes to use this function must #include. Hope this is clear.
7th Mar 2018, 5:06 PM
Udi Finkelstein
Udi Finkelstein - avatar