C++11的for
for (based on ranged)
 這個for循環是c++11提出的新的寫法,更加的簡潔了,不過感覺在運用上可能還是以前的for更加自由一點。
 ?
例子:
#include <QCoreApplication> #include <QDebug> #include <iostream> using namespace std;int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);QStringList listTemp;listTemp.append("a");listTemp.append("b");listTemp.append("c");for(QString strTemp : listTemp){qDebug()<<strTemp;}return a.exec();}foreach?
forever {
... } #include <QCoreApplication> #include <QDebug> #include <iostream> using namespace std;int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);QStringList listTemp;listTemp.append("a");listTemp.append("b");listTemp.append("c");QString strTemp1;QString strTemp2;foreach(strTemp,listTemp){qDebug()<<strTemp;}return a.exec();}?
總結
                            
                        - 上一篇: Qt学习笔记之QMainWindow,Q
 - 下一篇: 17.QT-事件处理分析、事件过滤器、拖