News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Possible to use string without string library

Started by Kayle, August 16, 2009, 12:14:04 AM

Previous topic - Next topic

Kayle

Hello,

I've discover code::blocks today and I'm very surprising by this very good IDE.

Unfortunately, I've a problem with the iostream and string libraries. During a test, I've seen that I've the possibility to use a string without make an include of <string>. In others terms, the code below works instead invoke an error:


#include <iostream>

int main(){
   std::string s1 = "C::B is the best.";
   std::cout << s1 << std::endl;
   return 0;
}


How is it possible and how can I avoid this? Because on VS2008 I've and error if I try to do that...

Sorry for my english, I'm french.

Thanks

Jenna

#1
Not related to C::B and therefore vioalting our forum rules.
Such a thread normally gets locked, so be warned.

Be aware C::b is "just" an IDE not a compiler.

Nevertheless:

iostream includes ostream,
ostream includes ios,
ios includes iosfwd,
iosfwd includes bits/stringfwd.h,
bits/stringfwd.h defines string in namespace std

that's the way gcc (at least 4.4) does it, Microsoft, Borland etc. compilers might do it in a different way.