From: horst DOT kraemer AT snafu DOT de (Horst Kraemer) Newsgroups: comp.os.msdos.djgpp Subject: Re: How can I tell if it's a bug from DJGPP or GCC? Date: Thu, 24 Sep 1998 11:14:15 GMT Organization: [Posted via] Interactive Networx Lines: 81 Message-ID: <360a2856.105452381@news.snafu.de> References: <6u7smk$9t7$1 AT nnrp1 DOT dejanews DOT com> <36078819 DOT 377336654 AT news DOT snafu DOT de> <3607D133 DOT E01E67CD AT dds DOT nl> <36080bfd DOT 411106352 AT news DOT snafu DOT de> <6ub2ln$j1r$1 AT nnrp1 DOT dejanews DOT com> NNTP-Posting-Host: n35-58.berlin.snafu.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Wed, 23 Sep 1998 15:04:23 GMT, D DOT J DOT Eleveld AT anest DOT azg DOT nl wrote: >In article <36080bfd DOT 411106352 AT news DOT snafu DOT de>, > horst DOT kraemer AT snafu DOT de (Horst Kraemer) wrote: >> On Tue, 22 Sep 1998 18:32:51 +0200, DougEleveld >> wrote: >> >> The scope of the declaration has nothing to do with scope of >> >> "destruction". The scope of "contruction" of singelton::instance is >> >> the scope of the class by definition. The scope of destruction is the >> >> scope of the definition - i.e. global scope. The d'tor is not >> >> accessible at global scope. >> >> >So you are saying that a static instance of a class does not have access >> >to it's own private constructors/destructors? >> >> Of course _it_ has not. Only member functions of the class have access >> to private member functions of the class. > >So you are saying that static members are destructed at file scope and it is >totally irrelevant who thier friends are and the scope of the construction? I never said anything about friends of a class. I said that the scope of construction of a static member of a class is the scope of the class. This has to be like this, because you have to _define_ a static member _outside_ the class definition at a scope which encloses the scope of the class - otherwise it would be impossible to _define_ a static instance of a class which has a non-public constructor. Destruction is handled differently. It is only possible if the d'tor is accessible from the scope of the _definition_ point. Therefore a static instance of a class _defined_ at file scope _must_ have a public destructor accessible at file scope. >Consider the following quite similar code: >class singelton >{ > private: > singelton() { }; > ~singelton() { }; > friend class wrapper; >}; >class wrapper >{ > public: > singelton nonstatic; > static singelton isstatic; >}; >singelton wrapper::isstatic; >The wrapper is allowed to have non-static singeltons, but not static >singeltons. This implies that public/private and friends mean something >different for static or non-static members which (i think) is very strange. What you call "means" boils down to: singleton nonstatic is _defined_ in the scope of class wrapper. Therefore its destruction takes place in the scope of class wrapper. class wrapper is a friend of class singelton. Therefore ~singelton() is accessible from the scope of the _definition_ point of 'nonstatic', even if it is private. If you like this or not: it is logical assuming that the scope of destruction of an object is the scope of its _definition_ point and not the scope of its _declaration_ point. For non-static data members this is the same. Static data members may be _declared_ in the scope of their class, but they _must_ be defined in a scope _enclosing_ their class, i.e. _outside_ the class. Therefore they need a d'tor accesible from this enclosing scope. Regards Horst