Undefined symbol

Hey guys. Im working on a random project. I declared 2 global variables above a bool function but the bool function wont compile because it says that "count" is undefined symbol

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <cstdlib>

using namespace std;

int used[32768],count=0;

bool isused(int num)
{
     for(int i=0;i<=count;i++) if(used[i]==num) return true;
     return false;
}


the for(int i...) is the line giving me the error.
There is an ambiguity between std::count and ::count. It appears that the implementation has gratuitously included <algorithm>

Resolve by
a. Not dumping using namespace std; at file scope
or b. Using an explicit scope resolution for( int i=0 ; i<= ::count ; ++i )
or c. Renaming the variable count to something else.
Thanks :)
C. is simpliest.
d. limiting the scope bool is_used(int used[] /*array[]*/, int count /*size*/, int num /*value*/);
Last edited on
Topic archived. No new replies allowed.