Muh*_*han 1 c++ iterator stl compiler-errors list
我正在尝试使用以下代码遍历字符串列表:
#include<cstdlib>
#include<string>
#include<list>
using namespace std;
list<string> dict = {"aardvark", "ambulance", "canticle", "consumerism"};
list<string> bWords = {"bathos", "balderdash"};
//splice the bWords list into the appropriate spot in dict
auto iterLastB = --(bWords.end());
//find spot in dict
list<string>::iterator it = dict.begin();
while(it != dict.end()){
if(*it > *iterLastB)
break;
++it;
}
dict.splice(it, bWords);
Run Code Online (Sandbox Code Playgroud)
然而,在构建这个时,我得到错误expected unqualified-id before 'while'
这是什么意思,我该如何解决这个问题?
| 归档时间: |
|
| 查看次数: |
3180 次 |
| 最近记录: |