Design a Inventory Class that can hold information for an item in a retail store's Inventory. I have to create an Inventory class with the private member variables itemNumber, quantity, cost, and totalCost. I have to have public functions including a default constructor, a second constructor that accepts itemNumber, quantity, and cost as arguments.Calls other class functions to copy these values into the appropriate member variables.
Heres my code my output seems to come out wrong any idea what it is I can't seem to see it?
Thanks,
Inventory(int itemNumber, int quantity, double cost)
{
itemNumber = getItemNumber(); // itemNumber has not been initialized, how can getitemNumber be called?
quantity = getQuantity();
cost = getCost();
setTotalCost(quantity, cost);
}
Change it to:
1 2 3 4 5 6 7
Inventory(int newItemNumber, int newQuantity, double newCost)
{
itemNumber = newItemNumber;
quantity = newQuantity;
cost = newCost;
setTotalCost(quantity, cost); // this can be called as quantity and cost have now been initialized.
}