I have a quick question regarding header files, inclusions and good coding style. Suppose I have 2 classes with corresponding source and header files, and then the final source file, where main () is located.
Inside Foo.hpp, I have the following statements:
#include <string> #include <iostream> #include <exception>
Now with Bar.hpp I have the following statements:
#include "Foo.hpp" #include <string>
And finally, with Myprogram.cpp, I have the following statements:
#include "Bar.hpp" #include <string> #include <iostream> #include <exception>
I know that the include statements in <> in Myprogram.cpp and Bar.hpp are not needed to compile and run the program, but what is the best practice or the right way to do something? Is there a reason why you do not explicitly include the necessary header files in each file?
source share