我正在尝试使用以下代码遍历字符串列表:
#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);
但是,在构建它时,我收到错误expected unqualified-id before 'while'
这是什么意思,我该如何解决这个问题?