Reputation: 1673
So I am working with some multidimensional vectors in C++ in NetBeans, and whenever I try to call the .size()
method, NetBeans marks it in red and says "Unable to resolve identifier size.". However, it does recognise other vector methods such as .push_back()
. The code compiles well though...
Here is my code:
#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
}
}
Here is a screenshot of the error highlighting:
Upvotes: 3
Views: 1186
Reputation: 1
The C++ default standard needs to be changed to C++ 11, rather than default, which is from the previous answer. I'm somewhat doubtful that any actual relatively up to date C++ standard leaves these functions out of the definition, but I can't say for certain, and I'm not sure what standard they are referring to as "default".
That's just stupid. Netbeans seems to require a lot of coddling and fiddling just to make it build code that works great pretty much everywhere. I haven't had issues like these since about 2000
Upvotes: 0
Reputation: 388
"Reparse Project" did not seem to do anything for me. The accepted answer from Rafayel Paremuzyan seemed to work initially but the errors returned. Instead, I found that the solution from https://stackoverflow.com/a/35025731/3389183 worked. The process is straightforward:
Upvotes: 3
Reputation: 147
I had exactly same symptoms, i.e. I had a vector defined, and it gave same error message "Unable to resolve identifier size", while it compiled succesfully.
Doing following helped:
Right click on the project->"Code Assistance" -> "Clean C/C++ cache and restart IDE"
Note: this is different from "RightClick on project"->"Code Assistance" ->"Reparse Project", which mentioned in several posts, but didn't help me.
Upvotes: 3