So how I do it is have a class for each item that has all the required data in it ready to be instanced into individual items. I have a manager class that loops through all the subfolders in a folder containing a config file for the item and any art assets the item needs. The manager class first loads the config file for each item and parses it then instances a new 'item' class for each item in the items folder.
I achieve that by using std::vector which allows me to make a dynamic list of the item classes:
// Create a new vector for all the items
//
// 'ItemClass' is the template class that holds
// all the data of all the items
//
// Use like std::vector<ClassName> VectorName;
std::vector<ItemClass> ItemList;
I gave a manager class a function 'Update()' which is run every game cycle to update the items. If the give your item class an 'Update()' function you can loop through the item list (vector) and call that function every time the manager class updates:
for (int i = 0; i < ItemList.size(); i++)
{
ItemList[i].Update();
}
So to load the items you loop through each subfolder containing the item data:
// Load the items
// Strings for filepaths
string absolutepath, path;
// Set the working dir
dbSetDir("Media");
// Clear the checklist
dbEmptyChecklist();
// Get a list of subfolders in 'media' by looping through it
dbPerformCheckListForFiles();
for (int i = 3; i < dbChecklistQuantity() + 1; i++)
{
// Create a absolute file path of the current
// subfolder and item data file
absolutepath = dbGetDir();
path = dbChecklistString(i);
absolutepath += ("\\" + path + "\\");
absolutepath += "ItemInfo.cfg";
// Create a new item class instance to use
ItemClass item;
// Add code to load the information from the item data file
// now that you have a file path to it
// Add the new item to the list of items
ItemList.pushback(item);
}