集合未插入
Set is not inserting
我遇到了一个问题,我的代码在试图插入集合时似乎被卡住了。
using namespace std;
set<string> * lexset;
void build( const set<string>& word_list )
set<string>::iterator it = word_list.begin();
while( it != word_list.end())
{
cout << *it << "before"<< endl;
lexset->insert(*it);
cout << "after" <<endl;
++it;
cout << "end of while" <<endl;
}
}
它似乎卡在了"之后"打印出来的行之前。
插入之前的行打印出一个字符串,我确信单词列表中包含了很多单词。这是编译的,不会循环。如果我删除插入,它会很好地遍历。为什么这个插件会引起这么多麻烦?
首先为lexset
:分配内存
lexset = new set<string>;
并修复您的word_list
打字错误
相关文章:
- 如何将结构插入到集合中并打印集合的成员
- 重载运算符的范围是什么?它是否会影响作为类成员的集合的插入函数?
- 将基元类型插入到集合中
- 如何在一对集合的向量中插入元素?vector<pair<int,set<string>>>
- 如何将值插入到 c++ boost::multiindex 集合的特定索引中,就像在 std::list 中一样
- 为什么以相同的数量插入到集合中,基于不同的方法具有不同的运行时间?
- 将地址插入到集合中,集合的大小小于预期
- 我可以在一行代码中将向量中与条件匹配的所有元素插入到集合中吗?
- 如何插入集合
- 如何在C++的集合中插入一系列元素
- 如何在集合中插入字符
- 将集合插入/读取到地图中
- 方法插入到任何stl集合中
- C - 如何将自己类型的值插入集合中
- 如何将数组插入无序集合
- 集合的复杂性::插入
- 将配对插入集合时编译错误
- 集合未插入
- 自定义比较器,将唯一元素插入到c++中的集合中
- 插入集合时出现分段错误