I have the follow code in VS2010:
#include <iostream>
int main()
{
std::string a = "ABC";
std::string b = "abc";
bool equal = a == b;
return 0;
}
Which gives an error on line 7:
error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
So it wasn't too surprising that iostream somehow includes string. What was surprising was that I only got part of the string functionality.
I know that standard fix is to also #include <string> so that operator gets declared, but I'm trying to ask a deeper question: if iostream was dragging in the string class, why wouldn't it want bring in the string class and all its other associated documented friends by including the string header? Is this just a poor implementation decision by Microsoft or is there a real gain to having string declared partially when iostream is included?
(Doing a quick check with GCC 3.4.4, it looks like it drags in the complete set of declarations for string because I don't get any compile errors.)

New Topic/Question
Reply


MultiQuote










|