Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6118

Re: Anonymous namespace

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail
From ruben safir <ruben@mrbrklyn.com>
Newsgroups comp.lang.c++
Subject Re: Anonymous namespace
Date Thu, 02 Jun 2011 22:40:37 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Lines 33
Message-ID <is9hj6$91p$1@reader1.panix.com> (permalink)
References <is9eqf$ft8$2@reader1.panix.com> <unnamed-namespace-20110603040622@ram.dialup.fu-berlin.de>
NNTP-Posting-Host www2.mrbrklyn.com
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Trace reader1.panix.com 1307068838 9273 96.57.23.82 (3 Jun 2011 02:40:38 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Fri, 3 Jun 2011 02:40:38 +0000 (UTC)
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10
In-Reply-To <unnamed-namespace-20110603040622@ram.dialup.fu-berlin.de>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:6118

Show key headers only | View raw


On 06/02/2011 10:07 PM, Stefan Ram wrote:
> ruben safir<ruben@mrbrklyn.com>  writes:
>> what is the anonymous name space and how is it accessed?
>
>    When an unnamed namespace is defined as in
>    (»...« denotes the contents, not to be read literally)
>
> namespace { ... }
>
>    , this is the same as
>
> namespace unique {} using namespace unique; namespace unique
> { ... }
>
>    , where »unique« is a unique (think: »compiler generated,
>    secret«) identifier used only for this namespace.
>

Can the object in the namespace be accessed in main with ::

namespace{
	int i;
}

int main(int argc, char * argv[] ){
	::i = 20;
	std::cout << i << std::endl;

}

What is the point of the anonymous namespace.

Ruben

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Anonymous namespace ruben safir <ruben@mrbrklyn.com> - 2011-06-02 21:53 -0400
  Re: Anonymous namespace Pete Becker <pete@versatilecoding.com> - 2011-06-02 16:00 -1000
  Re: Anonymous namespace ruben safir <ruben@mrbrklyn.com> - 2011-06-02 22:40 -0400
    Re: Anonymous namespace ruben safir <ruben@mrbrklyn.com> - 2011-06-03 02:29 -0400
      Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-03 20:12 +1200
        Re: Anonymous namespace Ruben Safir <mrbrklyn@panix.com> - 2011-06-04 02:40 +0000
          Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 15:40 +1200
            Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 04:56 +0000
              Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:19 +1200
                Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:37 +0000
                Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:40 +1200
        Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:05 +0000
          Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:31 +1200
            Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:42 +0000
      Re: Anonymous namespace Öö Tiib <ootiib@hot.ee> - 2011-06-03 06:08 -0700
        Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:09 +0000
          Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:32 +1200
            Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:39 +0000
              Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:45 +1200
    Re: Anonymous namespace gwowen <gwowen@gmail.com> - 2011-06-03 01:08 -0700
      Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-03 20:17 +1200
        Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:08 +0000
      Re: Anonymous namespace Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-03 09:44 -0400
        Re: Anonymous namespace Ruben Safir <mrbrklyn@panix.com> - 2011-06-04 02:44 +0000
        Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 15:57 +1200
        Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:14 +0000
          Re: Anonymous namespace "Bo Persson" <bop@gmb.dk> - 2011-06-04 11:33 +0200
  Re: Anonymous namespace Michael Doubez <michael.doubez@free.fr> - 2011-06-03 03:10 -0700
    Re: Anonymous namespace Ruben Safir <mrbrklyn@panix.com> - 2011-06-04 02:48 +0000
      Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 16:01 +1200
        Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:16 +0000
          Re: Anonymous namespace Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:34 +1200
  Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:01 +0000
    Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-09 11:26 +0000
      Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-10 04:12 +0000
        Re: Anonymous namespace Michael Doubez <michael.doubez@free.fr> - 2011-06-10 01:49 -0700
          Re: Anonymous namespace mrbrklyn <ceo.brooklyn@gmail.com> - 2011-06-10 10:34 -0700
          Re: Anonymous namespace mrbrklyn <ceo.brooklyn@gmail.com> - 2011-06-10 10:45 -0700
        Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-10 18:27 +0000

csiph-web