MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!panix.com!mrbrklyn From: Ruben Safir Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Sat, 4 Jun 2011 02:48:04 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 42 Message-ID: References: NNTP-Posting-Host: panix2.panix.com X-Trace: reader1.panix.com 1307155684 11543 166.84.1.2 (4 Jun 2011 02:48:04 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Sat, 4 Jun 2011 02:48:04 +0000 (UTC) User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (NetBSD/5.1 (i386)) Xref: panix comp.lang.c++:1085998
Michael Doubez wrote: > On 3 juin, 03:53, ruben safir 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.
> // 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?
Ruben > > -- > Michael -- end of forwarded message --
|
|