I have a class Foo with a corresponding .h and .cpp. Both files make use of an std::string. Should I only #include <string> in the header or include it in both files?
if the header can get away with a forward declaration then I always use that in the header and the #include in the implementation file. (FD can be used for reference and pointer types).
If they both need it, then i tend to put them in both so that if the header is changed I can remove it from the .h.
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