What is considered the universal proper way to organized files in C++? This is currently how I do it:
Function/class declarations in .h files, one .h per class/function, though occasionally I may have a "functions.h" file with small generic functions. I tend to organize it into folders as well.
Then the actual code goes into the .cpp file. In the .h I also include ifndefs to ensure if the header file is included more than once it will just get included once. Each header file includes any other headers that may be needed.
Then I have two main header files, includes.h and sources.h, and I have a little app that just auto generates a list of .h files in includes.h and a list of .cpp files in sources.h.
These two files are then included in the main program after including anything else.
I feel that this is probably not the right way. Is there a better way of doing it? It works, but it does rely on that custom app I wrote, or having to do it all manually.
I was also reading something where the .h file is actually included in the .cpp file of the respective class/function. How would that work as far as including it in your main program? I don't imagine you would include the .cpp files directly would you?
I know this is mostly just a schematics thing, but I want to move towards doing things a more proper way.
Function/class declarations in .h files, one .h per class/function, though occasionally I may have a "functions.h" file with small generic functions. I tend to organize it into folders as well.
Then the actual code goes into the .cpp file. In the .h I also include ifndefs to ensure if the header file is included more than once it will just get included once. Each header file includes any other headers that may be needed.
Then I have two main header files, includes.h and sources.h, and I have a little app that just auto generates a list of .h files in includes.h and a list of .cpp files in sources.h.
These two files are then included in the main program after including anything else.
I feel that this is probably not the right way. Is there a better way of doing it? It works, but it does rely on that custom app I wrote, or having to do it all manually.
I was also reading something where the .h file is actually included in the .cpp file of the respective class/function. How would that work as far as including it in your main program? I don't imagine you would include the .cpp files directly would you?
I know this is mostly just a schematics thing, but I want to move towards doing things a more proper way.