I have the following files:
test.hpp
class Test {
static constexpr const char* array[] {
"hello",
"world",
"!"
};
public:
void do_stuff();
};
test.cpp
void Test::do_stuff() {
for(int i = 0; i < 3; ++i) {
std::cout << array[i];
}
}
int main() {
Test object;
object.do_stuff();
}
This fails with the following linking error:
undefined reference to `Test::array'
So how can I define a constexpr array and then iterate over it?