Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ubc-cs!uw-beaver!milton!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!ns-mx!ccad.uiowa.edu!cadsi From: cadsi@ccad.uiowa.edu (CADSI) Newsgroups: comp.lang.c++ Subject: Re: Static member definition vs. declaration? Message-ID: <1991Apr30.195846.16760@ccad.uiowa.edu> Date: 30 Apr 91 19:58:46 GMT References: <1991Apr19.133728.5300@clear.com> Organization: CAD-Research, U. of Iowa, Iowa City, Iowa Lines: 26 From article <1991Apr19.133728.5300@clear.com>, by rmartin@clear.com (Bob Martin): > 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. > Correct, in C++ 2.0, static class members MUST be allocated outside the class structure. |----------------------------------------------------------------------------| |Tom Hite | The views expressed by me | |Manager, Product development | are mine, not necessarily | |CADSI (Computer Aided Design Software Inc. | the views of CADSI. | |----------------------------------------------------------------------------|