I’m trying to store the size of a queue in an int in C++. I’m pretty new to this, but I don’t know what I could be doing wrong. I get this error message:
“error: request for member ‘size’ in ‘free_men’, which is of non-class type ‘int’ ”
Here is the code:
I initialized the queue, and am just filling it with n numbers.
queue<int> free_men;
for(int i = 0; i < n; ++i) {
free_men.push(i + 1);
}
int free_men = free_men.size();
You have the same variable name for both the
queueand theint. Rename theintvariable.Surprising though that the error message isn’t more explicit.