Including files in a header vs implementation file
c++, header, implementation
Solution
The general principle is that you want to minimise dependencies wherever reasonably possible, so:
if your interface (.h) references anything in a given header then that header needs to be #included in the interface (.h)
if you only reference a given header in your implementation (.cpp) (and not in your interface) then you should only #include that header in the implementation
you should also try to only #include headers that are actually needed, although this can be difficult to maintain during the lifetime a large project
So for your example above, if you don't reference anything from globals.h in test.h, but you do reference it in test.cpp, then the #include should go in test.cpp. If you reference anything from globals.h in test.h though then you need the #include in test.h.
Problem
What's the difference between including a header file in a header file vs including it in a implementation file? This Ex: ``` // test.h #include"globals.h" class Test { Test(); }; ``` vs ``` //test.cpp #include"globals.h" Test::Test() { } ```