#include #include #define SIZE 12 using namespace std; template < class T > class InventoryItem { private: T m_Item; float m_Value; public: InventoryItem(T inItem, float inVal){ m_Item = inItem; m_Value = inVal; }; //get functions return member values T getItem(){ return m_Item; }; float getValue(){ return m_Value; }; }; //part b template class Inventory{ private: InventoryItem *m_pIvtItems[SIZE]; int m_Pos; public: Inventory(){ m_Pos = 0; } void Insert(InventoryItem *pInput){ if (m_Pos > SIZE){ throw string("Array is Full"); } m_pIvtItems[m_Pos] = pInput; m_Pos++; } void Print(){ for (int i = 0; i < m_Pos; i++){ cout << m_pIvtItems[i]->getItem() << ":"; cout << m_pIvtItems[i]->getValue() << endl; } } }; int main(){ Inventory inv; string itemName; float value; InventoryItem *pItem; cout << "Enter an item: "; cin >> itemName; while (itemName != "End"){ cout << "Enter item value: "; cin >> value; pItem = new InventoryItem("itemName", value); try { inv.Insert(pItem); } catch (string err){ cout << err << endl; delete pItem; } cout << "Enter an item: "; cin >> itemName; } cout << endl << "Inserted items: " << endl << endl; return 0; }