#9011 - hnager - Sat Jul 26, 2003 3:20 pm
Hey all - I'm having trouble declaring/defining a static member array. Instead oif having every instance of the class have it's own copy of the array I wanted to have it static in the class - I don't have any problems declaring/defining a single static variable:
That should work, right? Now how about an array?
If I take a similar approach to a single variable I get the following error when I compile:
ant.h:153: redeclaration of `int Ant::ant_personality[10]'
ant.h:39: `int Ant::ant_personality[10]' previously declared here
As far as I know, I can't define the array int he class declaration, how else would it be done? THanks again, Howard
Code: |
class Ant : public Sprite{
public: Ant(){}; ~Ant(){} ... private: static int ant_variable; }; int Ant::ant_variable = 0; |
That should work, right? Now how about an array?
Code: |
static int ant_personality[10]; |
If I take a similar approach to a single variable I get the following error when I compile:
ant.h:153: redeclaration of `int Ant::ant_personality[10]'
ant.h:39: `int Ant::ant_personality[10]' previously declared here
As far as I know, I can't define the array int he class declaration, how else would it be done? THanks again, Howard