• Advertisement
Sign in to follow this  

Pre-defined arrays help!

This topic is 4509 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this declaration of a variable that has its values defined in a header that fails to compile. Do you know how to make this work?
class Foo
{
public:

    static const unsigned int Bar[] = {0x55c636e2, 0x02be0170, 0x584b71d4};

};

Share this post


Link to post
Share on other sites
Advertisement
You need to intialize the array outside the class declaration. ex:

class Foo
{
public:

static const unsigned int Bar[];

};

// in a source file somewhere:
const unsigned int Foo::Bar[] = {0x55c636e2, 0x02be0170, 0x584b71d4};

Share this post


Link to post
Share on other sites
i _think_ that will only work for standard ints/floats;

for what your doing, IIRC,

.h

class C{
static const int array[3]
}

.cpp

const int C::array[3] = {...};

it compiled ( i didnt test ) on my machine...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement