我試圖解決一個無法解析的外部(link2019錯誤)。在StackOverflow上有很多關於這個問題的帖子,但是我不瞭解錯誤或者我對此不以爲意。無法解析的外部鏈接2019混淆
錯誤是由我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> &)" ([email protected]@[email protected]@@[email protected][email protected][email protected]@@Z) referenced in function "void __cdecl generate_maze(class Vector<int> &,class Grid<bool> &,class Maze &)" ([email protected]@[email protected]@@[email protected][email protected]@[email protected]@@Z)
1>C:\Users\com-user\Desktop\New folder\maze\assign3-maze-PC\Maze\Debug\Maze.exe : fatal error LNK1120: 1 unresolved externals
錯過包含或定義rand_neighbor()這裏有一點幫助http://stackoverflow.com/questions/9928238/unresolved-external-symbol-no-idea – Gilad 2013-03-14 22:48:50