dimanche 3 février 2019

For Loop with auto usage [duplicate]

This question already has an answer here:

I am using auto for the first time and I'm having trouble using it. I am creating a bubble sort algorithm with this program.

int values[SIZE] = {6, 2, 5, 8, 3};

cout << "Unsorted Values: " << endl;


for(auto element : values)
    cout << element << " ";

I am getting an error: 'element' does not name a type

Can someone explain what auto does

Aucun commentaire:

Enregistrer un commentaire