Newbie problem with the String class

Martin Piskernig martin.piskernig at stuwo.at
Thu Feb 10 16:46:16 GMT 2000


On Thu, 10 Feb 2000, you wrote:
> Eric Rouse wrote:
> 
> > I was just wondering, are you using namespace with those?  You should
> > be able to have something like...
> > 
> > using namespace std;
> > 
> > then:
> > 
> >    std::string myString("some text..");
> > 
> > Regards,
> > Eric
> 
> Just another dumb question: What does this "using" command do and what
> ist "namespace std" ?

Namespaces separate declarations to prevent name-conflicts (e.g. you have
a "const int A=3" in a.h and a "double A=3.3" in b.h, and you #include <a.h>
in b.h, which does not work). The "std" namespace is used by the C++ STL
include files e.g. <string> <iostream> (notice the file is WITHOUT .h). "using"
tells the compiler to make the namespace visible to the actual file without the
prefix. So, if "using namespace std" is given, you can write "string s" instead
of "std::string s".
Or just take a recent C++ introduction where namespaces will be explained much
better :-)
-- 
Martin Piskernig
<martin.piskernig at stuwo.at>    ICQ: 24015591
The KDevelop Team           www.kdevelop.org




More information about the KDevelop mailing list