Sign in to follow this  
Axiverse

Pre-defined arrays help!

Recommended Posts

Axiverse    366
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
SiCrane    11839
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
rip-off    10979
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this