C++列表未填写;

C++ list not filling;

本文关键字:列表 C++      更新时间:2023-10-16
list<string> Lexicon::startWith(char ch) {
    list<string> temp;
    string listWord;
    for (list<string>::iterator it = Words.begin(); it != Words.end(); ++it) {
        listWord=*it;
        if (ch == listWord[0])
            temp.push_back(listWord);
    }
    return temp;

临时列表未填充,.size返回 0

为了填满临时列表,您必须满足以下条件:

  • 单词容器不为空
  • 它至少包含一个以 ch 字符开头的单词