Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!uwm.edu!wuarchive!decwrl!ucbvax!agate!ragu!lippin From: lippin@ragu.berkeley.edu (The Apathist) Newsgroups: comp.std.c++ Subject: Scope of static member initializers Message-ID: <1990Aug1.030632.2273@agate.berkeley.edu> Date: 1 Aug 90 03:06:32 GMT Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 37 My pet peeve with C++ is that (accordong to CFront and a too-close reading of the AT&T language description) initializers for static data members of a class are in the public scope, rather than the scope of the class. Thus in a situation like this: class groupmember { public: static const groupmember zero; ... Zero can only be initialized through a public constructor, and even that constructor cannot be given any constants private to the class. As a remedy, I propose: 1) That the initializer of a data member have access to all members of the class. 2) That when the type of a static data member of a class is the class itself, aggregate initialization (e.g., {0,0,0}) be allowed. 3) That when the type of a static data member of a class is the class itself, ctor-initializers (e.g., :baseclass(17),somemember(0)) be allowed, provided that if any members are ctor-initialized, no aggregate initialization may follow. Aggregate initialization of structs and classes is something I've always found awkward (and non-robust), so I wouldn't really mind seeing it dropped entirely in favor of ctor-initializers -- although for the sake of the past, I suppose it must be kept. --Tom Lippincott lippin@math.berkeley.edu "Every action of theirs, that seems to them an act of their own free will, is ... in bondage to the whole course of previous history." --Leo Tolstoi