Pre-defined arrays help!

Started by
3 comments, last by Conner McCloud 18 years, 6 months ago
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};

};

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};
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...
Oh yea, thanks!
Quote:Original post by rip-off
i _think_ that will only work for standard ints/floats;

Not even floats. Just integral types.

CM

This topic is closed to new replies.

Advertisement