C ++ source code

I am new to C ++, background in Java and Python, the layouts of the source code in this language are pretty standard. However, I noticed that with C ++ projects, there are at least 3 different layout types:

Option 1 All files (.hpp and .cpp) in the same directory

---main folder
   |
   --- file1.hpp
   --- file2.hpp
   --- code1.cpp
   --- code2.cpp

Option 2 Headers (.h.pp) all in one include directory and implementations (.cpp) in src directory

---main folder
   |
   --- include
   |   --- file1.hpp
   |   --- file2.hpp
   |
   --- code
       --- code1.cpp
       --- code2.cpp

Option 3 Headers (.h.pp) all in one include directory with specific directories for different groups of headers (details, impl), all implementations (.cpp) in one directory

---main folder
   |
   --- include
   |   --- file1.hpp
   |   --- file2.hpp
   |   --- directory1
   |   |    --- code1.hpp
   |   --- directory2
   |        --- code2.hpp
   |
   --- code
       --- code1.cpp
       --- code2.cpp

Option 4 is similar to 3, but implementations also have their down directories.

---main folder
   |
   --- include
   |   --- file1.hpp
   |   --- file2.hpp
   |   --- directory1
   |        --- code1.hpp
   |   --- directory2
   |        --- code2.hpp
   |
   --- code
   |    --- code1.cpp
   |    --- code2.cpp
   |    --- directory1
   |    |    --- code1.cpp
   |    --- directory2
   |         --- code2.cpp

I quickly read the standard and can not find any suggestions or recommendations on this issue, the same applies to cppref documentation.

? : " "

+4
2

, , , . , . g++ , , make , , . # 4. , № 1, .

+5

?

. . .

+2

Source: https://habr.com/ru/post/1661116/


All Articles