Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6168
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Anonymous namespace |
| Date | 2011-06-04 16:01 +1200 |
| Message-ID | <94tp12FivcU3@mid.individual.net> (permalink) |
| References | <is9eqf$ft8$2@reader1.panix.com> <b339824c-511d-4564-bd89-bf4f07ac3285@h9g2000yqk.googlegroups.com> <isc6d4$b8n$3@reader1.panix.com> |
On 06/ 4/11 02:48 PM, Ruben Safir wrote:
> Michael Doubez<michael.doubez@free.fr> wrote:
>> On 3 juin, 03:53, ruben safir<ru...@mrbrklyn.com> wrote:
>>> what is the anonymous name space and how is it accessed?
>>
>> In brief, the effect is the same as C 'static' for functions and
>> global variables.
>>
> I'm confused because i thought what static did was create a variable
> which isn't destroyed between function calls and remembers its state.
> How that was accomplished, I'm uncertain of.
The static keyword suffers from overload abuse. In the global scope, a
static variable has local linkage, at function scope it does as you say
above.
>> // not in class of function scope
>> static int N; // N is only visible in file
>>
>> static void foo(){ // foo can only be called in file
>> // ...
>> }
>>
>> The interest is that it also work on type definition.
>>
>> namespace {
>>
>> // Bar can only be seen in file
>> class Bar
>> {
>> // ...
>> };
>>
>> }
>>
>> And it has also the same side effect that, when included in multiple
>> translation unit (through a header by example), each translation unit
>> will have its own definition of the class. This means that, by
>> example, class member variables are not shared.
>
> I thought class member variables are not shared by defauult?
I assumed he was referring to the member variable declarations.
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
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 Michael Doubez <michael.doubez@free.fr> - 2011-06-12 00:01 -0700
Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-10 18:27 +0000
csiph-web