Include files in .h file .cpp file or both?

I have written a code-snippet which makes use of headers (dohhh). Anyway, I have a class in source.h which has a function that uses sstream. So I thought I had to #include <sstream> to my header file, is this correct? And when I call the function in source.cpp should I #include <sstream> aswell? Thanks in advance luq
Last edited on
I'm going to assume you meant <sstream>, but anyway.
So, if you make use of sstream in the header, you just include it in the header.
Then, you include the header in the source.cpp file.
When you include a file, all of its inclusions are also included. So it kind of links together in a web.
Thus, you only need the inclusion in the header file.
Yeah, <sstream> (typo). Thanks thats all I needed to know! Cheers
Just be sure not to use precompiled headers, as far as I can tell what I said doesn't hold true if you sue precompiled headers.
Topic archived. No new replies allowed.