declare a array of const ints in C++ declare a array of const ints in C++ arrays arrays

declare a array of const ints in C++


class A {    static const int masks[];};const int A::masks[] = { 1, 2, 3, 4, ... };

You may want to fixate the array within the class definition already, but you don't have to. The array will have a complete type at the point of definition (which is to keep within the .cpp file, not in the header) where it can deduce the size from the initializer.


// in the .h fileclass A {  static int const masks[];};// in the .cpp fileint const A::masks[] = {0,1,3,5,7};