Multiple definition error, one definition
I am trying to finish off a text RPG, and a strange problem has cropped up. I get the error "multiple definition of [x]", and then a reference to where it was 'first' defined, being a function that only uses the objects, but does not define them. Here is a rundown of the set up:
In header ENTITIES_H, an array of items is created like this. The intention is for them to be global. ENTITIES_H uses #ifndef. Note that the compiler does not say the objects were first defined here. What are accused of being redefined are potion, ether, etc..:
Code:
Item items[5] = { potion, ether, bandage, eyeDrops, antigen };
These hold the characteristics of the items, and are only instantiated once. The inventory is an integer array that holds the number of each item held.
This header is included in two files, SHOP.CPP and PLAYER.CPP, which both make references like:
Code:
for (int i=0;i<5;i++) //Determine if the player has anything
{
int check = 0;
check += inventory[i];
if ( inventory[i] > 0 )
cout << i+1 << ". " << items[i].itemName << " - x" << inventory[i] << endl;
}
Why is the compiler telling me I am attempting to redefine them? There is absolutely no instantiation of class Item outside of ENTITIES_H.
Thanks!