I am not sure if that is a bug. I just took a brief look at the standard (section 21) and it mentiones that string is the one containning the operators. I am not sure where in the standard does it say that iostream should import all string operators.
I might be missing something so it would be great if you can provide me with more details.
There is already a lot of discussion in the C++ community that #include <iostream> already pulls in way too many other headers - and believe me it was not designed this way. Why should <iostream> pull in <string> The two are not related and there is really no reason why one should depend on the other.
We do provide every STL function and algorithm but our library, which is, BTW, provided by Dinkumware, was designed to minimize dependencies between the different components of STL.
If I am using string manipulation functions I expect to add #include <string> to my code, if I am using some algorithms I expect to have to add #include <algorithm>, if I want to use a vector I add #include <vector>.
Your code uses some functionality that is associated with string ... so I don't see why you have an issue with adding #include <string> to your code.
Would you expect the following to work
#include <iostream>
int main() { std::vector<std::string> strings; }
I know that I, and many other people in C++ community, would not expect this to compile.
Help needed with "error C2784"
belangereric
Srimurugan G
AndersW
Spidermans_DarkSide - VSIP
I might be missing something so it would be great if you can provide me with more details.
Thanks,
Ayman Shoukry
VC++ Team
EyalMSDN
I will look into the C2784 error that you are seeing
Thanks,
Ayman Shoukry
VC++ Team
HeatherA
Prerak Shah
There is already a lot of discussion in the C++ community that #include <iostream> already pulls in way too many other headers - and believe me it was not designed this way. Why should <iostream> pull in <string> The two are not related and there is really no reason why one should depend on the other.
We do provide every STL function and algorithm but our library, which is, BTW, provided by Dinkumware, was designed to minimize dependencies between the different components of STL.
If I am using string manipulation functions I expect to add #include <string> to my code, if I am using some algorithms I expect to have to add #include <algorithm>, if I want to use a vector I add #include <vector>.
Your code uses some functionality that is associated with string ... so I don't see why you have an issue with adding #include <string> to your code.
Would you expect the following to work
#include <iostream>
int main()
{
std::vector<std::string> strings;
}
I know that I, and many other people in C++ community, would not expect this to compile.
Brian Seekford
I usually test the code first in VS.NET 2003 than I convert the project into VS.NET 2005.
It was a normal Wizard Win32 Console application.
Capt. Mick
edutrom
John Fran
At the top, add:
#include <iostream>
#include <string>
using namespace std;
I got the same error, and it works for me after adding the #include. I am not sure why the rest of the code compiles without #include<stream>.
Brian
zogman
Kevin P
The fact that some other compiler uses <string> in their implementation of <iostream> doesn't mean every compiler should.
AndreaMasi