所以我在 NetBeans 中使用 C++ 中的一些多维 vector ,每当我尝试调用 .size()
方法时,NetBeans 将其标记为红色并显示“无法解析标识符大小。 ”。但是,它确实可以识别其他 vector 方法,例如 .push_back()
。虽然代码编译得很好......
这是我的代码:
#include <vector>
using namespace std;
typedef vector<int> int1D;
typedef vector<int1D> int2D;
int2D populate (int2D arg1, int arg2);
int main () {
//Do stuff...
}
int2D populate (int2D grid, int gridSize) {
int2D my_2d_array;
//Here I fill my_2d_array...
for (int x = 0; x < gridSize; x++) {
for (int y = 0; y < gridSize; y++) {
int value = grid[x][y];
if (value == 0) {
//get all coordinaes of values with 0
int1D coordinates;
coordinates.push_back(x);
coordinates.push_back(y);
my_2d_array.push_back(coordinates);
}
}
}
for (int x = 0; x < my_2d_array.size(); x++) {
//do something
}
}
这是错误突出显示的屏幕截图:
最佳答案
我有完全相同的症状,即我定义了一个 vector ,并且 它给出了相同的错误消息“无法解析标识符大小”, 编译成功。
执行以下操作有帮助:
右击项目->“代码帮助”->“清理C/C++缓存并重启IDE”
注意:这与“RightClick on project”->“Code Assistance”->“Reparse Project”不同,后者在几个帖子中提到过,但对我没有帮助。
关于c++ - Vector size() 被 NetBeans 标记为错误 : Unable to resolve Identifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52863280/