不需要再看,我发现了错误,但是在八个小时之前我不能回答自己,因为我得几分。把价值传递给一个函数
我想要在类函数“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);
}
这不是一个编译器错误,它是一个链接器错误。 –
为什么'&*迷宫'而不仅仅是'迷宫'? –