My H File
Code
class Inventory
{
private:
int itemNumber; //Holds the item's item number
int quantity; //Holds the quantity of the items
double cost; //Holds the wholesale per-unit cost of the item
double totalCost; //Holds the total inventory cost ( quantity * cost )
public:
//Constructors
Inventory();
Inventory(int inum, int quant, double price);
//Mutators
void setItemNumber(int inum);
void setQuantity(int quant);
void setCost(double price);
void setTotalCost(int quant, double price);
//Accessors
int getItemNumber()
{
return itemNumber;
}
int getQuantity()
{
return quantity;
}
double getCost()
{
return cost;
}
double getTotalCost()
{
return totalCost;
}
};
My Cpp File
Code
//Sets all the memnber variables to 0
Inventory::Inventory()
{
itemNumber = 0;
quantity = 0;
cost = 0;
totalCost = 0;
}
//Accepts an item's number, cost, and quantity as arguments. The function
//should copy these values to the appropriate member variables and then call
//the setTtotalCost function.
Inventory::Inventory( int inum, int quant, double price )
{
itemNumber = inum;
quantity = quant;
cost = price;
setTotalCost(quant, price);
}
//Accepts an integer argument that is copied to the itemNumber memeber variable
void Inventory::setItemNumber(int inum)
{
if ( inum >= 0 )
itemNumber = inum;
else
itemNumber = 0;
}
//Accepts an integer argument that is copied to the quantity member variable.
void Inventory::setQuantity(int quant)
{
if ( quant >= 0 )
quantity = quant;
else
quantity = 0;
}
//Accepts a double argument that is copied to the cost member variable
void Inventory::setCost(double price)
{
if ( price >= 0 )
cost = price;
else
cost = 0;
}
//Calculates the total inventory cost for the item (quantity * cost) and
//stores the result in totalCost
void Inventory::setTotalCost(int quant, double price)
{
totalCost = quant * price;
}
My Errors
inventoryclient.cpp:40: error: no matching function for call to 'Inventory::setTotalCost()'
inventory.h:30: note: candidates are: void Inventory::setTotalCost(int, double)
inventoryclient.cpp:56: error: no matching function for call to 'Inventory::setTotalCost()'
inventory.h:30: note: candidates are: void Inventory::setTotalCost(int, double)
This post was edited by SlayingWhileInt0xicated on Nov 11 2012 08:54pm