MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
From owner-hangout-outgoing-at-mrbrklyn.com Sun Jun 5 00:27:57 2011 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix) id 95F7A100BE1; Sun, 5 Jun 2011 00:27:55 -0400 (EDT) Delivered-To: hangout-outgoing-at-www2.mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix, from userid 28) id 24A1E100B9B; Sun, 5 Jun 2011 00:27:54 -0400 (EDT) Delivered-To: hangout-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by www2.mrbrklyn.com (Postfix) with ESMTP id BCD47100BA0 for ; Sun, 5 Jun 2011 00:27:25 -0400 (EDT) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 031D232F17 for ; Sun, 5 Jun 2011 00:27:39 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 20529) id E7EF133C6F; Sun, 5 Jun 2011 00:27:38 -0400 (EDT) From: Ruben Safir To: hangout-at-nylxs.com Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (NetBSD/5.1 (i386)) Message-Id: <20110605042738.E7EF133C6F-at-panix2.panix.com> Date: Sun, 5 Jun 2011 00:27:38 -0400 (EDT) Sender: owner-hangout-at-mrbrklyn.com Precedence: bulk Reply-To: hangout-at-mrbrklyn.com
-- forwarded message -- Path: reader1.panix.com!panix!newsfeed-00.mathworks.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Sat, 04 Jun 2011 16:01:38 +1200 Lines: 46 Message-ID: <94tp12FivcU3-at-mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net raWyRs+NA15yKRA4A16KHAIn0cRXdPbZFQN0UmQPsaBEbOUHOw Cancel-Lock: sha1:sXoAKnXnBNIwqoaIsU8fnbv3cOI= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: panix comp.lang.c++:1086001
On 06/ 4/11 02:48 PM, Ruben Safir wrote: > 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.
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 -- end of forwarded message --
|
|