Honestly, I'm not to great with maps. So far I fixed up to the orange line, I'm not sure what to do with the display() and remove() functions (I will do the function overload thing later)
Code:
void add(sitem stuff);
void displaythings();
void remove(int number);
map<sitem, int> inventory;
int amount;
int main()
{
add(sword);
add(poop);
add(longsword);
cout << amount;
poop.id = 2;
//remove (0);
displaythings();
system("Pause");
return 0;
}
void add(sitem stuff)
{
inventory.insert( make_pair(stuff, 5));
}
--------------------------------------------------------
void displaythings()
{
for (:map<sitem, int>::iterator i = inventory.begin(); i != inventory.end(); ++i)
{
std::cout << '(' << i->id << ')' << i->name << "\t" << std::endl << '\t' << i->description << endl;
}
}
void remove(int number)
{
for (std::map<sitem, int>::iterator i = inventory.begin(); i != inventory.end();)
{
if (i->id == number)
{
i = inventory.erase(i);
break;
}
}
}