我正在尝试解决未解决的外部问题(link2019 错误)。StackOverflow 上有很多关于这个问题的帖子,但要么我不理解错误,要么我对此视而不见。
该错误是由我的 generate_maze 函数引起的(特别是由 rand_neighbor() 调用,对吗?),但我的理解是这些都已“解决”。
我稍微截断了代码,因为它非常冗长。我希望这是适当的。
void generate_maze (Vector<int> &coords, Grid<bool> &included, Maze &m);
int main() {
Grid<bool> included = initialize_grid();
Vector <int> coords = rand_coords();
Vector <int> current_point = coords;
generate_maze(coords, included, m);
return 0;
}
void generate_maze (Vector<int> &coords, Grid<bool> &included, Maze &m) {
while (gridIsTrue == false) {
Vector<int> neighbor = rand_neighbor(coords, included);
pointT neighborpoint = {neighbor[0], neighbor[1]};
pointT current_point = {coords[0], coords[1]};
if (included.get(neighbor[0], neighbor[1]) == false) {m.setWall(current_point, neighborpoint, false); included.set(neighbor[0], neighbor[1], true); current_point = neighborpoint;}
}
}
Vector<int> rand_neighbor(Vector<int> &coords, Grid<bool> &included) {
while (1) {
int randomint;
randomint = randomInteger(1,4);
if (randomint == 1) {if (included.inBounds(coords[0], coords[1]+1)) {coords[1] = coords[1]+1; break;}}
if (randomint == 2) {if (included.inBounds(coords[0], coords[1]-1)){coords[1] = coords[1] -1; break;}}
if (randomint == 3) {if (included.inBounds(coords[0] -1, coords[1])){coords[0] = coords[0] -1; break;}}
if (randomint == 4) {if (included.inBounds(coords[0] +1, coords[1])){coords[0] = coords[0] + 1; break;}}
}
return coords;
错误:
error LNK2019: unresolved external symbol "class Vector<int> __cdecl rand_neighbor(class Vector<int>,class Grid<bool> &)" (?rand_neighbor@@YA?AV?$Vector@H@@V1@AAV?$Grid@_N@@@Z) referenced in function "void __cdecl generate_maze(class Vector<int> &,class Grid<bool> &,class Maze &)" (?generate_maze@@YAXAAV?$Vector@H@@AAV?$Grid@_N@@AAVMaze@@@Z)
1>C:\Users\com-user\Desktop\New folder\maze\assign3-maze-PC\Maze\Debug\Maze.exe : fatal error LNK1120: 1 unresolved externals