lundi 8 août 2016

'for' loop vs Qt's 'foreach' in C++

Which is better (or faster), a C++ for loop or the foreach operator provided by Qt? For example, the following condition QList<QString> listofstrings; Which is better? foreach(QString str, listofstrings) { //code } or int count = listofstrings.count(); QString str = QString(); for(int i=0;i<count;i++) { str = listofstrings.at(i); //Code }

Aucun commentaire:

Enregistrer un commentaire