g++ Ärger

Jan-Benedict Glaw jbglaw at lug-owl.de
Wed Apr 20 09:05:42 CEST 2005


On Tue, 2005-04-19 12:59:22 +0200, Klaus Reinke <zuffmick at t-online.de> wrote:
> On Monday 18 April 2005 09:21, Jan-Benedict Glaw wrote:
> >
> > using namespace std;
> 
> ich gloob ich werd senil, sowas wusste ich doch mal
> 
> neuer Code:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> #include<iostream>
> #include<string>
> 
> string s1 = "Hallo";
> 
> int main()
> {
>         std::cout << s1 << "!\n";
>         return 0;
> }
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 
> g++ cout.cpp:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> cout.cpp:4: error: Fehler beim Parsen before `=' token
> cout.cpp: In function `int main()':
> cout.cpp:8: error: `s1' undeclared (first use this function)
> cout.cpp:8: error: (Each undeclared identifier is reported only once for each 
>    function it appears in.)
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Das ist immernoch derselbe Fehler, wie vorher. Der Typ "string" ist nur
im namespace "std" vorhanden. Entweder behältst Du "using namespace
std;" bei--oder Du mußt Dir den string explizit daraus besorgen:

std::string s1 = "Hallo";

MfG, JBG

-- 
Jan-Benedict Glaw       jbglaw at lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lug-owl.de/pipermail/linux/attachments/20050420/1dfb9a0d/attachment.sig>


More information about the Linux mailing list