[TriLUG] OT: String.h in g++ around Redhat 5.0

Randall Barlow randall_barlow at ncsu.edu
Fri Jun 16 08:06:19 EDT 2006


Guthrie, Joshua L CIV NAVAIRDEPOT wrote:
> 	I get errors:
> 	No member function 'String::find(char)' defined
> 	No member function 'String::erase(int, unsigned int)' defined
> 	No member function 'String::c_str()' defined
>
> 	These seem to be on lines that I use the data type String...
>
> 	My namespace warning, and my inability to find a sstream.h, or
> get String to work started to make me wonder if I had slipped into a
> twilight zone of comiler history in linux...
>   
Hey Josh - instead of the statement "using namespace std;" I would 
recommend "using std::string" along with "using std::otherThingsYouUse" 
just in case you use things that have the same name as other things in 
the std namespaces from other libraries or your own code.  I'm no C++ 
expert, but that's just what I would recommend.  Also, I've been able to 
use the stringstream (I think this is what you are trying to use 
sstream.h for) without an sstream.h.  It's in either <iostream> or 
<string> (I honestly can't remember which - but I've included both of 
these in some old code I have that uses stringstreams...)  You can add a 
line that says "using std::stringstream;" with your using statements.  
Alternatively, you can just give the scope every time you use these 
things, such as:

std::string mString = "Hello World!";

This way you don't need the using std::string at the top - but it 
clutters your code...

HTH,
R



More information about the TriLUG mailing list