inventory for RPG text game
hey everyone, so im kinda knee deep in making my first major program and i was wondering how i should go about making my inventory for the player. i'm using c++ and have considered using a class (but am not quite sure how since i just got started on classes) or using new to create new memory somehow for each new inventory item and then place it somewhere. . . .somehow. . . .to be recalled later. any help would be appreciated! thanks
Use a vector to store your items in. You items must all be the same type.
Something like this:
Something like this:
struct item{ std::string name; std::string description; ...};std::vector<item> items;
I recommend you use vectors, as previously mentioned.
Vectors are much like arrays, but have much more functionality and accessibility, along with them being dynamic (they can change their size easily).
Vectors are much like arrays, but have much more functionality and accessibility, along with them being dynamic (they can change their size easily).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement