Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!nucsrl!tellab5!balr!clrcom!rmartin From: rmartin@clear.com (Bob Martin) Newsgroups: comp.lang.c++ Subject: Re: Static member definition vs. declaration? Message-ID: <1991Apr19.133728.5300@clear.com> Date: 19 Apr 91 13:37:28 GMT References: <1848@dinl.mmc.UUCP> Organization: Clear Communications, Inc. Lines: 21 In article <1848@dinl.mmc.UUCP> noren@dinl.UUCP (Charles Noren) writes: >We have a debate in our group. When you declare a static >member, such as: > > class X {static int myVar;}; > >Do you need to make a definition elsewhere, > > int X::myVar; > Although the source will compile without the definition, I have been unable to get it to link without it. It seems that (at least with Sun's 2.0 compiler) the declaration in the class is _not_ a definition, and that a true definition is required. -- +-Robert C. Martin-----+:RRR:::CCC:M:::::M:| Nobody is responsible for | | rmartin@clear.com |:R::R:C::::M:M:M:M:| my words but me. I want | | uunet!clrcom!rmartin |:RRR::C::::M::M::M:| all the credit, and all | +----------------------+:R::R::CCC:M:::::M:| the blame. So there. |