"no matching function call..." 此错误来自哪里,我该如何解决?
"no matching function call..." Where is this error coming from and how can I resolve it?
我在第 3 行遇到了一个问题 - "调用 std::vector::p ush_back(int*)const 没有匹配函数" - 有人可以向我解释这个问题来自哪里以及如何解决它吗?
for(int i = 1; i < 7; i++){
for(vector< vector<int> >::const_iterator it = x.begin(); it < x.end(); it++){
it->push_back(i);
}
}
您正在使用const_iterator
进行迭代。根据定义,您无法修改const_iterator
引用的内容。 请改用非常量iterator
:
for(vector< vector<int> >::iterator it = x.begin(); it != x.end(); it++){
it->push_back(i);
或者,更好的是,您应该使用现代 C++11 或更高版本:
for (auto &x_vector: x)
x_vector.push_back(i);
你不认为现代C++更容易写和理解吗?
相关文章:
- 运行同一解决方案的另一个项目的项目
- Project Euler问题4的错误解决方案
- Ardunio UNO解决了多个重叠的定时器循环
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 两个文件使用彼此的功能-如何解决
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 在java中解决这段代码时面临循环中的问题
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 难以理解某些人解决IOI问题的源代码
- visual c++,如何获取解决方案目录中的代码
- 如何解决错误:SCIP C++中的 SCIP 阶段无效 <10>
- 节俭并发:未解决的外部问题
- IpOpt拒绝解决不受约束的问题
- 如何解决这个超硬恒星的创造问题
- 循环无限运行C++解决骑士之旅问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- C++Matching Brackets 2解决方案不起作用
- 在 ubuntu3 上C++ goto 定义有什么解决方案吗16.04?
- 为什么这段代码不起作用,我该如何解决?