Mail Archives: djgpp/1997/06/06/17:32:37
John Eccleston wrote:
> #include <stdio.h>
>
> 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
- Raw text -