delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/25/19:30:36

From: "bowman" <bowman AT montana DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <3B7CEDE9 DOT 17D0DCC9 AT hotmsil DOT com> <ihrqntgo5rd50bnmq8lr76pt7bsn1r6sk3 AT 4ax DOT com> <3B7F0AB9 DOT 5080903 AT operamail DOT com>
Subject: Re: Problem compiling c++
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <JKQh7.174$IF5.131060@newsfeed.slurp.net>
Date: Sat, 25 Aug 2001 10:53:59 -0600
NNTP-Posting-Host: 208.4.224.32
X-Trace: newsfeed.slurp.net 998758441 208.4.224.32 (Sat, 25 Aug 2001 11:54:01 CDT)
NNTP-Posting-Date: Sat, 25 Aug 2001 11:54:01 CDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Sahab Yazdani" <sahaby AT operamail DOT com> wrote in message
news:3B7F0AB9 DOT 5080903 AT operamail DOT com...
>
> > using namespace std;
> ^^^^^^^^^^^^^^^^^^^^^^
> what does this do?? I have a bunch of books on C++, but i've never run
> across this line b4.

you might want to update your C++ references. Try Stroustrup's 3rd Edition.
A current C++ compiler will reject :

        cout << "Hello World" << endl;

and require you to qualify the references to the std namespace as:

       std::cout << "Hello World" << std::endl;

the 'using namespace std;' tells the compiler that you are, indeed, pulling
in functions from the std package and you will not have to qualify each
usage. While this is handy, it negates the attempt to reduce namespace
pollution, and should be applied sparingly. For instance, if you had two
packages providing the function 'do_it()', qualifying them as pkg1::do_it()
and pkg2::do_it() avoids the compiler errors and also removes ambiguity for
the human reader.



- Raw text -


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