0

How do I reference a vector array in multiple cpp files and headers

The folowing gives the error: undefined reference to `function(std::vector >&)'|

main.cpp

functionD(arr);
cout << arr[3] << endl;

header.h

extern vector<string> arr;
int functionD(vector<string> arr);

functions.cpp

vector<string> arr;

int functionD(vector<string>& arr){

arr.push_back("0");
arr.push_back("1");
arr.push_back("2");
arr.push_back("3");
arr.push_back("4");
arr.push_back("5");
arr.push_back("6");
arr.push_back("7");

return 1;

}

0 Answers0