delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/05/17/06:02:09

From: anthony AT prairienet DOT org (Anthony)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trouble Compiling C++ with DJGPP
Date: 17 May 2003 02:58:15 -0700
Organization: http://groups.google.com/
Lines: 36
Message-ID: <e3d7c716.0305170158.4aa64651@posting.google.com>
References: <e3d7c716 DOT 0305161346 DOT 61886eff AT posting DOT google DOT com> <3EC5615B DOT 6000704 AT earthlink DOT net>
NNTP-Posting-Host: 130.126.25.115
X-Trace: posting.google.com 1053165496 5630 127.0.0.1 (17 May 2003 09:58:16 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: 17 May 2003 09:58:16 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Martin Ambuhl <mambuhl AT earthlink DOT net> wrote in message news:<3EC5615B DOT 6000704 AT earthlink DOT net>...
> Anthony wrote:
> 
> > --Snippet--
> > #include <iostream>
> > 
> > int main()
> > {
> >     cout << "Hello world.\n";
> >     return(0);
> > }
> > -----------
> > 
> > --Error--
> > hello.cc: In function 'int main()':
> > hello.cc:5: 'cout' undeclared (first use this function)
> > hello.cc:5: (each identifier reported only once)
> > ---------
> 
> [Description of much wasted effort]
> 
> cout is part of the std namespace in C++.  You must say so, in any 
> implementation of the real language C++, including g++.  One way of 
> doing so is:
> 
> #include <iostream>
> 
> int main()
> {
>      std::cout << "Hello world.\n";
>      return 0;
> }

Thanks. This works perfectly with g++. I still wonder why I was able to
compile the snippet in the past without the std:: though. It is an exact
quote out of a recent book on C++.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019