Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!odi!valens!dlw From: dlw@odi.com (Dan Weinreb) Newsgroups: comp.lang.c++ Subject: Re: Can you initialize private static data members? Message-ID: <405@odi.ODI.COM> Date: 1 Aug 89 12:56:53 GMT References: <11327@brunix.UUCP> <404@odi.ODI.COM> <24121@santra.UUCP> Sender: news@odi.com Reply-To: dlw@odi.com Lines: 24 In-reply-to: jaa@hutcs.hut.fi's message of 1 Aug 89 05:03:36 GMT In article <24121@santra.UUCP> jaa@hutcs.hut.fi (Jari Alasuvanto) writes: According to Stroutrup`s BOOK, a static member cannot be of a class with a a constructor (page 275). Has this been changed in 2.0 ? Yes. My problem with static members (for the reason above I have mostly used pointers and allocated them explicitely) is: what is the right place to do the initialization. In C++ 2.0, it works just as "extern" variables do in C (and C++). The initialization appears at file scope (at top level). Typically the class definition is in a header file, and the initialization is in one of the source files that includes that header file. I think that the problem is basically the fact that in C++ clases are not objects as in pure OO languages. No, there's no "purity of OO" problem here. The only reason that there's anything complex going on here is because of the C model of separate compilation and linking. If everything were always all in one big file, all of this would be completely simple. Dan Weinreb Object Design, Inc. dlw@odi.com