不需要再看,我發現了錯誤,但是在八個小時之前我不能回答自己,因爲我得幾分。把價值傳遞給一個函數
我想要在類函數「Draw」中聲明的函數「fillBorderVertexes」傳遞一個指針(它在Window類中聲明並在其構造函數中賦值),但編譯器會拋出此錯誤:
1>window.obj : error LNK2019: unresolved external symbol "void __cdecl fillBorderVertexes(class TransparentMaze *,class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > > *,float,float,int)" ([email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected]@[email protected]) referenced in function "public: virtual void __thiscall Window::draw(void)" ([email protected]@@UAEXXZ)
1>C:\Users\Asus\Desktop\VC++\PacMan\Debug\PacMan.exe : fatal error LNK1120: 1 unresolved externals
它是否與這樣的事情有關,在這個函數內部的指針值或其某些部分是不可見的?
void Window::draw() {
::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
::glLoadIdentity();
void fillBorderVertexes(TransparentMaze*, vector<vector<GLfloat>>*, GLfloat, GLfloat, int);
void fillMazeVertexes(vector<vector<GLfloat>>*, Room*, GLfloat, GLfloat, int);
void drawMaze(vector<vector<GLfloat>>*, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
static vector<vector<GLfloat>> borderVertexes;
static vector<vector<GLfloat>> mazeVertexes;
static bool done = false;
std::map<Point, Room*, compare>::iterator it = maze->getMaze().begin();
GLfloat x = ((GLfloat)it->first.getX() - 0.5f) * (room + border) - ((GLfloat)maze->getWidth()/2.0f * (room + border));
GLfloat y = ((GLfloat)maze->getHeight()/2.0f * (room + border)) - ((GLfloat)it->first.getY() - 0.5f) * (room + border);
if (!done) {
// The problem is in this function with the first variable
fillBorderVertexes(&*maze, &borderVertexes, room, border, ANGULAR_CORNERS);
fillMazeVertexes(&mazeVertexes, &*it->second, room, border, ANGULAR_CORNERS);
done = true;
}
drawMaze(&mazeVertexes, x, y, imageW, imageH, imageD);
::SwapBuffers(hdc);
}
這不是一個編譯器錯誤,它是一個鏈接器錯誤。 –
爲什麼'&*迷宮'而不僅僅是'迷宮'? –