I would like to know what are C++ best practices when it comes to organizing my project. I've read that I should put all the source files (.cpp) in the src folder and header files (.h) should be placed in the include folder. Is it the way it is supposed to be, or should I put my header files in the source files folder?
This is my folder tree structure
- Project
|
+--- src (.cpp)
|
+--- include (.h) ????
|
+--- test (cpp unit test)
|
+--- doc (docs)
Writing to a file (fprintf or fputs)
The header file eliminates the labor of finding and changing all the copies as well as the risk that a failure to find one copy will result in inconsistencies within a program. In C, the usual convention is to give header files names that end with .
It is a matter of preference really but organization of a code base helps for maintainability as well as for easily understanding the code. One should have an Modular approach as much as possible. Your code organization just looks about almost right, Ideally I would have:
- Project
|
+--- src (.cpp)
|
+--- include (.h) ????
|
+--- test (cpp unit test)
|
+--- doc (docs)
|
+--- bin (generated binaries)
|
+--- lib (external dependencies)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With