Because this works just fine:
Code:#include <iostream> using namespace std; int main(){ string SayHello = "Hello"; cout<<SayHello<<endl; return 0; }
Because this works just fine:
Code:#include <iostream> using namespace std; int main(){ string SayHello = "Hello"; cout<<SayHello<<endl; return 0; }
It is completely implementation-dependent which standard headers include other standard headers. Therefore this code may or may not compile, depending on the standard library implementation.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Does it mean that <iostream> header include <string>??It is completely implementation-dependent which standard headers include other standard headers.
It tottaly depends on u dude ,,,,
actually std is a namespace so when u r saying that using namsepsace std; means what ever will be in that namespace will be available to u.....
it depends on u if u donu wanna that
code like this
Code:#include <iostream> int main() { string SayHello = "Hello"; std::cout << SayHello << std::endl; return 0; }
Yes, some <iostream> implementations include <string> (probably indirectly), while others perhaps don't include it.
For example, your code compiles with GCC and Comeau Online, but not with MSVC. If you want your code to compile the same with all compilers, you'll need to include all the headers you need, even if with some compilers some of these inclusions are redundant.
using namespace std; is irrelevant here, because the std namespace will only contain those things at that point which have been declared in the included headers. If you don't include <vector> (either directly or through some other header), that won't be enough to make std::vector visible. (Namespaces are open: in each header they are "opened up" again, and more stuff is declared to be part of it.)
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.