I have some code in C++:
// A.h
extern const char *names[3];
// B.cpp
#include "A.h"
const char *names[3] = {
"Name1",
"Name2"
"Name3"
};
void getName()
{
char *name;
strncpy(name, names[0], 5);
};
// C.cpp
#include "A.h"
Then when I build it, it generate the following error:
undefined reference to `names' What is the reason and how to fix it?