gpt4 book ai didi

c++ - 在 C++ 中无效使用列表迭代器

转载 作者:太空宇宙 更新时间:2023-11-04 15:10:15 25 4
gpt4 key购买 nike

整数 = 0; 列表::迭代器它; for(it = binary.const_iterator; it !=binary.end();++it) { 如果(*它=='1'){ abc.push_back(copyoflist.at(num)); } 数++;

这里binary定义为list binary;copyoflist是一个char类型的vector。

我收到这个错误:无效使用“std::list >::const_iterator”在线

for(it = binary.const_iterator; it !=binary.end(); ++it)

我无法弄清楚出了什么问题。有人可以帮助我吗?

最佳答案

const_iterator 是一种类型,而不是属性。你会像这样使用它:

 list<char>::const_iterator it;
for(it = binary.begin(); it != binary.end(); ++it)

关于c++ - 在 C++ 中无效使用列表迭代器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3257465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com