MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h9g2000yqk.googlegroups.com!not-for-mail From: Michael Doubez Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Fri, 3 Jun 2011 03:10:46 -0700 (PDT) Organization: http://groups.google.com Lines: 32 Message-ID: References: NNTP-Posting-Host: 62.160.54.163 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1307095847 32496 127.0.0.1 (3 Jun 2011 10:10:47 GMT) X-Complaints-To: groups-abuse-at-google.com NNTP-Posting-Date: Fri, 3 Jun 2011 10:10:47 +0000 (UTC) Complaints-To: groups-abuse-at-google.com Injection-Info: h9g2000yqk.googlegroups.com; posting-host=62.160.54.163; posting-account=4_dwSAoAAAD_OEYz89wEMQOvnJlm6isC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: panix comp.lang.c++:1085964
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.
// 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.
-- Michael -- end of forwarded message --
|
|