java - Advantages/Disadvantages of Header Files -


What are the advantages and disadvantages of using header files like a language in Java like C or C ++ languages? I think classrooms should be designed from outside, so it is good to have header files and not so much through the implementation details. However, then, then, each function declaration is repeated in two files. If C and C ++ are invented today, would they use the header file? Is this system old or important?

"post-text" itemprop = "text">

Eric Lipper is derived from the concerned, which keeps it very well:

I equivalent The question why C + + requires header files ? Header files look like a huge potential point of failure; Every time I edit the C ++ code and change the signature of any method; If I forget to update the header file, the code is not compiled and often gives some hidden error messages. Hopefully this big price actually buys something to you.

The compiler author buys one thing and the user buys one thing.

It buys a user that you can compile each person. Line Cppâ ???? File file in a file is provided independently, provided you have all the necessary headers, all the information needed to create the bodies present in a CDP file can be obtained from the set of header. This means that the build system can only compile those CPP files which have changed, provided no headers have changed.

What does the compiler buy the author is that every file can be compiled in one pass? ??? Since each type and method announcement is first processed before usage , the compiler can start easily from the top of the file, drag all included headers Can move forward at the top, obj file to get out, as it goes, go back and do not see anything that has already been seen.

This is contrary to languages ​​like C # (which is a blog post) and Java, which is a close relative.

Comments