+ 2
Prototypes let you separate interface from implementation. Real-world programs are composed of multiple .cpp files (aka compilation units), frequently compiled and linked into libraries before being linked into final executable form. For large-scale projects of that nature, prototypes are collected into .h files (aka header files), where the header is included in other compilation units at compile time to alert the compiler to the existence and calling conventions of functionality in the library. In these cases, the function definition is not available to the compiler, so the prototypes (aka declarations) serve as a sort of contract defining the library's capabilities and requirements. source: https://stackoverflow.com/questions/3763960/purpose-of-c-c-prototypes
9th Mar 2022, 1:32 PM
Nima