Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!avraamid From: avraamid@camelback.crd.ge.com (David Avraamides) Newsgroups: comp.lang.c++ Subject: Re: Static member definition vs. declaration? Message-ID: Date: 24 Apr 91 12:13:43 GMT References: <1848@dinl.mmc.UUCP> <186@devnull.mpd.tandem.com> <37226@ditka.Chicago.COM> Sender: news@crdgw1.crd.ge.com Organization: GE Corporate Research & Development Lines: 22 In-reply-to: comeau@ditka.Chicago.COM's message of 21 Apr 91 17:10:55 GMT In article <37226@ditka.Chicago.COM> comeau@ditka.Chicago.COM (Greg Comeau) writes: # In article <186@devnull.mpd.tandem.com> kelley@mpd.tandem.com (Michael Kelley) writes: # >In article <1848@dinl.mmc.UUCP>, noren@dinl.uucp (Charles Noren) writes: # >> class X {static int myVar;}; # >> Do you need to make a definition elsewhere, # >> int X::myVar; # >> I claim you do (and of course you want to initialize it # # You *do*. A static member only serves as a declaration, and not a # definition hence a definition still needs to be provided. # What if its not public? Does this make sense? I use a static numInstances variable in my root class and ++ it in all constructors and -- it in all destructors. I don't want it to be publicly visible. What if I don't want it to start at 0? (My compiler doesn't make me initialize it.) -- Dave Avraamides avraamides@crd.ge.com All opinions are my own...