Hi, how can I store an object in a hash_map? I have an Item object and I want to pair it with a quantity. Will I be able to: 1. Find the item? 2. change the paired quantity? 3. sort it by qty or item name?
/*Item.h handles the item in game*/
#ifndef ITEM_H
#define ITEM_H
#include <string>
class Item
{
public:
Item(): name("NoName"), desc("NoDesc"), used(false){};
Item(std::string IDesc, std::string IName) : name(IName), desc(IDesc), used(false){};
~Item(){};
bool useable(){ return !used; }
void useItem(){ used = true; }
std::string getName() const { return name; }
std::string getDesc() const { return desc; }
private:
std::string name;
std::string desc;
bool used;
};
#endif