I noticed that in different C ++ projects, programmers use the #include directive in different ways
1) In the first case, include to the maximum prescribe in h-files, but no longer write in cpp-files. Those. you make the inclusion of one header file, and he already pulls all the inclusives in him.
2) In the second case, on the contrary, there are almost no include in h-files, but all these include will be written in cpp-files. However, if there are some common classes, then they can do this:
At the beginning of the header file put an empty class declaration: class myClass; . But this include will be in the cpp-file.
There is no external data type declaration in the header file at all. But it works if you connect header files with a description of classes in the cpp-file before connecting dependent header files, i.e. order is important
My questions are:
- Is there a formal name for these source line layout styles?
- How to do it right, but how can you not do it?
- I want to explore this topic inside and out. Where to begin?
.cppfiles, and put in in.honly when this can not be avoided. However, often used dependencies are better to render in a separate.h. If you are using MSVC, the total unchanged part is better to render tostdafx.h. - VladD