I get a compiler error when programming the following:
- file1.cpp: declaring/defining of several variables
- file1.cpp: defining a pointer array that is pointing to each of these variables -> this array shall be const (=always point to these variables)
- file2.cpp: here I want to use the pointer array and use the variables it points to.
//file1.cpp
int a,b,c,d;
int *const pa[4] = {&a, &b, &c, &d};
//file2.cpp
extern int *const pa[4];
when compiling it drops the error in file2.cpp:
undefined reference to `pa'
How to define that pointer array with constant pointers and use it in different source files?
Best regards :-)