mercredi 24 juin 2020

Whats the difference between these two range based loops

int main()
{             
       map<float,float>m;
       //input some value in m
        for(auto it=m.end();it!=m.begin();it--)
        {
           cout<<it.first<<" "<<it.second;
           
        }
    
    return 0;
}

The above code is not working now if instead of the above code I use the code below, its working perfectly fine. Idk why is it happening please tell me what is the difference.

int main()
{             
       map<float,float>m;
       //Input some value in m
        for(auto it:m)
        {
           cout<<it.first<<" "<<it.second;
        }

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire