how to make it working correct(libstdc++)?

Nathan Myers ncm-nospam@cantrip.org
Mon Aug 12 04:38:00 GMT 2002


On Mon, Aug 12, 2002 at 11:48:40AM +0300, Christoph Bugel wrote:
> You should write it this way:
> 
> #include <iostream>
> #include <string>
> using namespace std;
> 
> int main()
> {
>   string str("hello world!");
>   cout<<str<<endl;
>   return 0;
> }

It's time to stop recommending "using namespace std;" in user code.  
The standard library defines far too many names for people to be 
expected to remember them all.  The canonical program is better
expressed as:

#include <iostream>
#include <string>

int main()
{
  std::string str("hello world!");
  std::cout << str << std::endl;
  return 0;
}



More information about the Libstdc++ mailing list