From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: [Q] Static class member variables Date: Fri, 06 Jun 1997 01:56:02 -0700 Organization: Alcyone Systems Lines: 42 Message-ID: <3397D0A2.3E63F481@alcyone.com> References: <865334760 DOT 165475 AT red DOT parallax DOT co DOT uk> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk John Eccleston wrote: > #include > > class clsTest > { > public : > static int instanceCount = 0; > > public : > clsTest() { instanceCount++; }; > ~clsTest() { instanceCount--; }; > > virtual int getInstanceCount(void) { return instanceCount; }; > }; This is not legal; you cannot give initializers for static members inside the class declaration. (Such member declarations are _declarations_, not definitions.) You need to declare the static member and then define it separately to avoid the errors: class clsTest { public: static int instanceCount; // ... }; int clsTest::instanceCount = 0; // ... -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Covenants without the sword / are but words." / Camden