global variable outside a class??

i had a global variable but not above int main(), but above a class,something like this
1
2
3
4
5
6
//global variable
int* map;
int MAX_WIDTH;
class map{
//definiton and method
};

but when i compile it,it says that in main function there is multiple definition of map and MAX_WIDTH. but i also can't move it because the method in map class needs the map and MAX_WIDTH. What should i do?
Thanks for your help
What should i do?


- You shouldn't use globals.

- You shouldn't have a variable and a class both named the same thing.

- 'map' is probably a poor choice anyway since it may conflict with std::map.


If these variables are related to your map class, why not make them part of your map class?
I also want to insert it to my class, but something i forgot to tell you that the int*map values is depends on another class, okay i'll explain my real problem. i'm trying to use the source od a* algorithm from google code. but the definition of the "world map" in the code is global variable. what i need is i get the "world map" from another class. So here is the story line:
first i'll make the user to create the "world map",
then i'll pass the map to a* star algorithm class to get the cost of the travel

so, i really confuse how to integrate the code to my problem,
if you need the a* code here is the link:
http://code.google.com/p/a-star-algorithm-implementation/downloads/list

thanks for your help, i really stuck on this problem.
Topic archived. No new replies allowed.