[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OFFTOPIC: How to use strings with libstdc++?



On Tue, 29 Dec 1998, Wojciech Zabolotny <wzab@ipe.pw.edu.pl> wrote:

> I've stated that there is no old good String class in libstdc++.
> Instead I've found the "string" header which defines the "string" class.
> Is it OK to use it in new C++ programs, or it is added only for
> compatibility? Why has it such nonstandard name (without ".h" suffix).

Wojciech

There is some difficulty with the <string> class semantics.  The library
with egcc provides "rope" class that is said to fix some of the semantics. 
I hope soneone can clarify this question.

The ANSI C++ standard provides many new features which most compilers are
more or less tracking. Among them is a full set of template container and
algorithm libraries, a string class <string> and namespaces.

The standard provides for the C++ specific headers to have no extension. 
These headers include a bunch of headers equivalent to ANSI C headers,
such as cmath for example. The new C++ headers that are equivalent to the
C headers have much the same information in them as do the originals,
except (I think) they have C++ linkage, giving full type checking. 

The differences between the behavior of .h headers and headers without is
that the .h headers dump their symbols into the global namespce, whereas
those headers without dump their symbols into namespace std.

Whether you have to deal with namespace depends on your compiler.  In all
the g++/egcc compilers I know about, namespaces vary from "mostly broken"
to "don't work terribly well". 

You can find out about a substantial subset of the STL and <string> from
Tim Budd's Data Structures in C++ with the Standard Template Library, AWL,
ISBN 0 201 30897 7. There are better books for experienced programmers.
I'm sorry I don't have one at my finger tips right now.  Authors like
Musser and Saini, Brett Glass, Nelson come to mind.  Ping me back and
I'll look up some pointers to these sources. 

Hope this helps.

--David Teague    dbt@elentari.cs.wcu.edu
Debian GNU/Linux: Because reboots are for kernel and hardware upgrades.



Reply to: