Skip to main content
gamedev.net
🔒 Locked

Static Arrays

Started by johndunne 1 reply 300+ views
Original Post
johndunne
johndunne
Hello all, hoping someone can help me out. I''m trying to add a static array to a class. I''ve got public: static LONGLONG array[ 100 ]; Now the problem I have is defining the array, I get a link error. With a variable defingin is easy. LONGLONG CClass:variable = 0; will do the job. But, can anyone tell me how you define the array? Thanks in advance
I'm all dunne now
Poontardis
Poontardis
--------
Blah.h
--------

class Blah
{
private:
static const int m_Array[100];
};

-------
Blah.cpp
--------

const int Blah::m_Array[100] =
{
0,
1,
2,
.
.
.
99
};

[edit:] oops sorry, slightly misread. If you don't want the data to be const just get rid of the const keywords + you'll be able to modify the values at runtime if you wish.

[edited by - poontardis on January 15, 2003 8:48:21 AM]
johndunne
johndunne
Thanks for the reply Poontardis, and sorry for a delayed response. Thats solved the problem nicely, thanks again.
I'm all dunne now

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.