www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/19/09:45:12

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help in my codes.
Date: 19 Sep 2002 13:39:46 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 39
Message-ID: <amck32$1ph$1@nets3.rz.RWTH-Aachen.DE>
References: <am3jv2$vbr$1 AT reader01 DOT singnet DOT com DOT sg> <3voboug43iagagl91bk5o4buuu2is8fava AT 4ax DOT com> <am4ptt$7g0$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <am8no9$ll2$1 AT mawar DOT singnet DOT com DOT sg> <am9n2n$qb2$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <ambdit$t2j$1 AT mawar DOT singnet DOT com DOT sg> <amce00$pb7$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <amci6e$nu$1 AT mawar DOT singnet DOT com DOT sg>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1032442786 1841 137.226.32.75 (19 Sep 2002 13:39:46 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 19 Sep 2002 13:39:46 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Kim Seng <Query AT singnet DOT com DOT sg> wrote:

> Any example on this "std::" coding?

Before ANSI/ISO C++ Standard, all things in the standard library were
accessible just by their name, i.e. to access the standard output
stream you would write:

	#include <iostream.h>

	//...
	cout << "blabla" << nl;

The Standard moved them all into a namespace called "std", so the
actual name of cout is now std::cout.  It also changed the names of
the standardized header files to not have a ".h" at the end:

	#include <iostream>

	//...	
	std::cout << "blabla" << nl;

"using namespace std;" tells the compiler that you want all things in
the namespace "std" to become available in your program's space,
without those std:: prefixes.

The idea behind namespaces is to avoid conflicts of like-named things
from indepentant sources (the language standard, some vendor's
library, a third-party library, your own source code, ...).  Like the
one between the function "count" provided by the C++ Standard Template
Library (STL for short) and your original example's variables called
"count", too.  Because of namespaces, you can keep calling your
program's own variable "count", but still access the STL function as
std::count.


-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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