Article View: comp.std.c++
Article #1244Initialization of private static members
From: Marc Girod
Date: Tue, 15 Dec 1992 13:23
Date: Tue, 15 Dec 1992 13:23
39 lines
1948 bytes
1948 bytes
Hi net world!
------------------------------------------------------------
// stinit.C
class A {
private:
A();
static A a;
};
A A::a; //HP CC v 3.0: error: global scope cannot access A::A(): private member (1298)
//
//GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
//stinit.C: In function `void _GLOBAL_$I$_1A$a ()':
//stinit.C:5: constructor `A::A ()' is private
//stinit.C:7: in base initialization for class `A'
------------------------------------------------------------
The ARM states p 180 that 'Static members obey the usual member access
rules except that they can be initialized (in file scope)'.
This allows a private static member to be initialized, as long as the
constructor for its class is public.
Are my compilers correct in refusing me the access to private
constructors, to build a private static member?
Sorry if this has already been dealt with...
Best Regards!
--
+-----------------------------------------------------------------------------+
| Marc Girod - Nokia Telecommunications Phone: +358-0-511 7703 |
| TL4E - P.O. Box 12 Fax: +358-0-511 7432 |
| SF-02611 Espoo 61 - Finland Internet: marc.girod@ntc.nokia.com |
| X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc |
+-----------------------------------------------------------------------------+
Technical Details
Message-ID:
<GIROD.92Dec15152324@node_262d6.tele.nokia.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!tele.nokia!girodShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!tele.nokia!girod From: girod@tele.nokia.fi (Marc Girod) Subject: Initialization of private static members Message-ID: <GIROD.92Dec15152324@node_262d6.tele.nokia.fi> Sender: usenet@noknic.nokia.fi (USENET at noknic) Nntp-Posting-Host: rat.ts.tele.nokia.fi Reply-To: marc.girod@ntc.nokia.com Organization: kpd Distribution: comp Date: Tue, 15 Dec 1992 13:23:24 GMT Lines: 39