So I want to have a struct like this:
struct A {
static constexpr int arr[10] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};
};
In which I have a static constexpr array. If I try to access this array for example with this function:
int main(){
for (int i = 0; i < 10; i++){
printf("%i ", A::arr[i]);
}
}
It says I have an undefined reference to 'A::arr'
.
How am I supposed to access this array?
I have tried using a getter function in the class like:
static constexpr int get(int index){
return arr[index];
}
I also tried declaring an instance of the class, and accessing it through that:
A a;
printf("%i", a.arr[0]);