Archived

This topic is now archived and is closed to further replies.

Sphere

STL, iostream.h

Recommended Posts

Hello guys, I have a problem, I was wondering if anyone can help. In my code I use STL and a scripting library. The library header files have lots of #include and overload << operator to perform output. The problem is that whenever there is a line: ostream& operator<<(ostream&,const sometype &s); in the library, MSVC++ 6.0 complain about ostream being ambiguous, my question is "is there anyway I can use STL and ostream from iostream.h peacefully?" Since the library I am using is not my own, so I can''t possibly change it to use STL instead. Thanks a lot.

Share this post


Link to post
Share on other sites
Well, my first instinct is that you shouldn''t be using #include <iostream.h>, you should be using #include <iostream>. These are subtly different in that the .h prefix is for the ''old'' streams and removing the .h is for the new streams, which are more compatible with the STL. This might solve your problem.

Share this post


Link to post
Share on other sites
Kylotan''s 100% correct. Be sure when you switch over (and you should--nobody should be using the .h versions of the stream libraries) that you are aware that everything will now be in namespace std. This means you''ll either have to put std:: before the types and names you expect to have (i.e. ostream, cout), or you''ll have to put "using namespace std" somewhere.

Share this post


Link to post
Share on other sites
Thanks guys, I rearrange where I put using namespace std; now I can get it to work find.

Thanks again

Share this post


Link to post
Share on other sites