Hi, I have an Item class, how can I make my Item object be composed of more Item objects? Say I have a gun and its composed of more items like bullet and magazine, how can i make it do that?
/*Item.h handles the item in game*/
#ifndef ITEM_H
#define ITEM_H
#include <string>
class Item
{
public:
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