home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!news.funet.fi!ajk.tele.fi!funic!nokia.fi!tele.nokia!girod
- From: girod@tele.nokia.fi (Marc Girod)
- Subject: New try: Access to private constructor for building a private static member
- In-Reply-To: girod@tele.nokia.fi's message of Tue, 15 Dec 1992 14:59:03 GM
- Message-ID: <GIROD.92Dec23081920@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
- References: <GIROD.92Dec15165903@node_262d6.tele.nokia.fi>
- Distribution: comp
- Date: Wed, 23 Dec 1992 06:19:20 GMT
- Lines: 46
-
- Hi net world!
-
- I got only one answer to this posting, a week ago (the subject was:
- Initialization of private static members), telling me that the code in
- my example works under xlC (RS6000 C++).
-
- But nobody answered about whether it SHOULD work or not...
-
- ------------------------------------------------------------
- // 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!
- ...And incidentally, Merry Christmas!
- --
- +-----------------------------------------------------------------------------+
- | 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 |
- +-----------------------------------------------------------------------------+
-