I have made a program that introduces a class, Inventory, that holds a given number of items introduced by the constructor. Observe:
What I am aiming to do is delete an individual member of the array. Is this possible? I have tried to delete it through my "Remove" function but...:Code:class Inventory { public: Inventory() { cItems=new Item[defaultSize]; suiCap=defaultSize; } Inventory(short unsigned int suiSize) { cItems=new Item[suiSize]; suiCap=suiSize; } ~Inventory() { delete [] cItems; } Remove(short unsigned int suiIndex) { delete cItems[suiIndex]; } protected: Item* cItems; short unsigned int suiCap; private: static short unsigned int siDefaultSize; }; static int Inventory::siDefaultSize=32; Inventory myInv(10);
This gives me compiler errors, saying that Item * cannot be converted to void *.Code:myInv.Remove(5);
So, any workaround to this?



LinkBack URL
About LinkBacks


