Thread View: comp.std.c++
1 messages
1 total messages
Started by Marc Girod
Tue, 15 Dec 1992 13:23
Initialization of private static members
Author: 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 |
+-----------------------------------------------------------------------------+
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads