[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: gcc 3.2 (g++)
From: Michael Schuerig <schuerig () acm ! org>
Date: 2002-10-30 22:35:52
[Download RAW message or body]
On Wednesday 30 October 2002 22:57, Kevin Krammer wrote:
> On Mittwoch, 30. Oktober 2002 22:37, Pieter Breed wrote:
> > hi
> >
> > this is not on-topic, I apologise. I have a g++ question but I do
> > not know where else to post to.
> >
> > I want to use the "string" class from the c++ STL. I #include
> > <string> but I get an error like the compiler does not recognise
> > the string type.
> >
> > I have:
> > ---<code>---
> > string rnrgenerator::getNameOfRNG(int i) { // line 56
>
> You either specify the correct namespace at the return type (std::)
> or tell the compiler that you want to use the namespace.
>
> so either
> using namespace std;
> somewhre before that code, r
> std::string mrgenerator::getNameOfRNG(int i)
Please don't put
using namespace std;
in a header file that may be used by others.This would more or less
defeat the purpose of namespaces. In the words of Bjarne Stroustrup "I
consider nonlocal using-directives primarily a transition tool"
(CppPL3, p. 183). There's no problem with such a using-directive in an
implementation (.cpp) file.
Even in a header file you can do something like this
struct C {
std::string m() {
using namespace std;
return string("Hi");
}
};
Michael
--
Michael Schuerig If at first you don't succeed...
mailto:schuerig@acm.org try, try again.
http://www.schuerig.de/michael/ --Jerome Morrow, "Gattaca"
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic