[try Beta version]
Not logged in

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

May 14, 2010 at 7:12pm
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 May 14, 2010 at 7:40pm
May 14, 2010 at 7:16pm
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.
May 14, 2010 at 7:41pm
Yeah, <sstream> (typo). Thanks thats all I needed to know! Cheers
May 14, 2010 at 9:17pm
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.