Answer the question
In order to leave comments, you need to log in
Why are prototypes needed in C++?
Good afternoon. I started learning C ++ after PHP and some questions arose:
1) Header files: do they contain prototypes of library functions? (and that's all?)
2) How does the compiler find the necessary built-in functions by prototypes if we do not include the library file in the cpp file, but only include the header file with #include?
3) As I understand it, prototypes in C ++ are needed in order to compile faster?
4) Header files are already compiled code? (object)
5) The same question as in 4, only about libraries
Don't ask me why I need to know, I'll just sleep better I'm
learning from a book, pretty good (Stephen Prata) so please do not send me to smoke manuals or go on coding in php and html, this book does not answer my questions
Answer the question
In order to leave comments, you need to log in
1) Header files: do they contain prototypes of library functions? (And that's all?)
1) In the header file, data types, function prototypes, the function body itself, templates can be declared. All this can be declared in cpp.
2) This is what the linker does.
3) This is one of the reasons. The second is the resolution of visibility problems.
For example, try writing mutually recursive functions without prototypes.
4) No
5) No
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question