在我的int main()代碼段中,我聲明瞭一個標識符(tile)。在某些行上,標識符認爲它是未聲明的,而在其他行上則認爲它是聲明。初始聲明在所有括號之外(主要除外)。爲什麼會發生?在同一段代碼中聲明和未聲明的標識符 - C2065 VS2010 C++
int main(int argc, char* args[])
{
//Quit flag
bool quit = false;
//The dot
Dot myDot;
//The tiles that will be used
Tile *tiles[ TOTAL_TILES ];
//The frame rate regulator
Timer fps;
//Initialize
if(init() == false)
{
return 1;
}
//Load the files
if(load_files() == false)
{
return 1;
}
//Clip the tile sheet
clip_tiles();
//Set the tiles
if(set_tiles(tile) == false)
{
return 1;
}
//While the user hasn't quit
while(quit == false)
{
//Start the frame timer
fps.start();
//While there's events to handle
while(SDL_PollEvent(&event))
{
//Handle events for the dot
myDot.handle_input();
//If the user has Xed out the window
if(event.type == SDL_QUIT)
{
//Quit the program
quit = true;
}
}
//Move the dot
myDot.move(tiles);
//Set the camera
myDot.set_camera();
//Show the tiles
for(int t = 0; t < TOTAL_TILES; t++)
{
tiles[ t ]->show();
}
//Show the dot on the screen
myDot.show();
//Update the screen
if(SDL_Flip(screen) == -1)
{
return 1;
}
//Cap the frame rate
if(fps.get_ticks() < 1000/FRAMES_PER_SECOND)
{
SDL_Delay((1000/FRAMES_PER_SECOND) - fps.get_ticks());
}
}
//Clean up
clean_up(tile);
return 0;
}
我的問題是clean_up (tile);
和set_up (tile);
- 或者至少這就是我的錯誤代碼排隊。
包含錯誤消息/堆棧跟蹤 – eebbesen