在代码C2065 VS2010 C++的同一部分中声明和未声明的标识符

Identifier both declared and undeclared in same section of code - C2065 VS2010 C++

本文关键字:声明 标识符 未声明 一部分 代码 C2065 VS2010 C++      更新时间:2023-10-16

在我的int main()代码段中,我声明了一个标识符(tile)。在某些行中,标识符认为它是未声明的,而在其他行中,它识别它的声明。初始声明位于所有方括号之外(主声明除外)。为什么会发生这种情况?

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 );——或者至少这是我的错误代码所在。

tiletiles不是同一标识符。