How to make an inventory system?

It's really hard to tell without knowing every detail of your specification but you could do something like code below. Keep in mind that this is in C and it's just a mock-up;

struct Item {
    some_var_for_item_type; // enum ,enum class or something else
    void * data;
    ItemInfo * item_info;

struct ItemInfo {
    char * name; 
    unsigned int usable : 1;
    unsigned int breakable : 1;
    unsigned int stackable : 1;


struct GunData {
    GunInfo * gun_info;
    int cur_ammo;
    int attachment_list[max_attachments];

    struct GunInfo {
    int fire_rate;
    int max_ammo;

struct FoodData {
    FoodInfo * ...
    int stacks;
    int cur_nutrition_value;

Then you create an array for each of those infos you need ,and w/e else (vector ,array ,...) for all the actual data. eg. two ak-47s have the same pointer to item_info and the same data->gun_info but different cur_ammo and attachment_list

/r/gamedev Thread