я получаю следующее сообщение об ошибке, когда я пытаюсь скомпилировать мой код:Ошибка Apple Mach-O Linker? Помогите пожалуйста
Undefined symbols for architecture x86_64:
"findCentralAtom(int, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
я не уверен, что я должен сделать, так как я новичок в C++.
vector<int> findCentralAtom(int dist, const vector<string>& list) {
int numAtoms = int(list.size());
vector<int> centralAtom = {0,0};
for(int i = 0; i < numAtoms; i++) {
int count = 0;
for(int k = 0; k < numAtoms; k++) {
double temp = 0;
temp = returnDistance(i, k, list);
if(temp != 0 && temp < dist) {
count++;
}
}
if(count > centralAtom[1]) {
vector<string> tempVec = splitter(list[i]);
centralAtom[0] = atoi(tempVec[4].c_str());
centralAtom[1] = count;
}
}
return centralAtom;
}
/*
int main() {
....
//caAtoms is a string vector
vector<int> central = findCentralAtom(10, caAtoms);
}
*/
Есть ли причина, по которой они должны соответствовать? Центральная часть вектора содержит целые числа и не зависит от параметра вектора строки. Разве это не похоже на возвращение целочисленного значения из строкового аргумента? – soochism
См. Дополнение к ответу – Eric