gpt4 book ai didi

c++ - 如何获得非常量迭代器

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:55:02 24 4
gpt4 key购买 nike

std::map<char,int> dict;
...
auto pmax = dict.begin(); // here i get const iterator

我可以“明确指出”获取的值是非常量类型吗?

最佳答案

如果您的 dict不是 const , begin 将返回 std::map<char,int>::iterator .现在,关键是 const ,但值不是。

auto应该给你一个std::map<char,int>::iterator ;你有相反的证据吗?

关于c++ - 如何获得非常量迭代器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15758629/

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