stupid g++ question

Jerry Feldman gaf at blu.org
Thu Mar 14 14:33:45 EST 2002


The subject says it all. 
#include <iostream.h>
#include <string>
using namespace std;
int main()
{
        string s;
        s = "Hello, world!";
        cout << s << "\n";
}
There are better ways of doing this, but the addition of using namespace std; solves the problem. 
Apparently, Red Hat 7.2 (gcc 2.96) solves this either as a compiler default or by altering the 
header files. 
Of course, I could have opened by eyes when I looked at the string header file, (actially, 
bits/basic_string.h, where string is actually defined within namespace std. 
It's been about 4 years since I have done any profesisonal C++ coding.  Jerry Feldman 
<gaf at blu.org>
Associate Director
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9




More information about the Discuss mailing list