i'm making a quick class that has some getters and setters. i'm getting an error at line 46 when i try and create my setItemNumber function. Im also getting an unexpected EOF error but i think that it might have to do with my first error. this is my code....
#include <iostream>
using namespace std;
class Inventory
{
private:
int itemNumber;
int quantity;
double cost;
double totalCost;
public:
Inventory();
Inventory(int,double,int);
int setItemNumber;
int setQuantity;
double setCost;
double setTotalCost;
int getItemNumber;
int getQuantity;
double getCost;
double getTotalCost;
};
Inventory::Inventory()
{
itemNumber = 0;
quantity = 0;
cost = 0;
totalCost = 0;
}
Inventory::Inventory(int n, double c, int q)
{
itemNumber = n;
cost = c;
quantity = q;
//setTotalCost();
}
void Inventory::setItemNumber(int n)
{
if(n > 0)
itemNumber = n;
else
{
cout << "Invalid width\n";
exit(EXIT_FAILURE);
}
void Inventory::setQuantity(int q)
{
if(q > 0)
quantity = q;
else
{
cout << "Invalid width\n";
exit(EXIT_FAILURE);
}
void Inventory::setCost(double c)
{
if(c > 0)
cost = c;
else
{
cout << "Invalid width\n";
exit(EXIT_FAILURE);
}
void Inventory::setTotalCost(int q, double c)
{
totalCost = q*c;
}
double Inventory::getCost() const
{
return cost;
}
double Inventory::getTotalCost() const
{
return totalCost;
}
int Inventory::getItemNumber() const
{
return itemNumber;
}
int Inventory::getQuantity() const
{
return quantity;
}
int main()
{
Inventory invent;
int Number;
int Quant;
double Cost;
cout << "This program will store data and calculate cost of items.\n";
cout << "Please enter the number for the item to be bought.";
cin >> Number;
cout << "Please enter the quantity of items you want.";
cin >> Quant;
invent.setitemNumber(Number);
invent.setQuantity(Quant);
invent.setCost(Cost);
invent.setTotalCost(Quant,Cost);
cout << "This is the data for the purchase:\n";
cout << "Item Number: " << invent.getitemNumber() << endl;
cout << "Item Quantity: " << invent.getQuantity() << endl;
cout << "Item Cost: " << invent.getCost << endl;
cout << "Total Cost of your purchase: " << invent.getTotalCost << endl;
return 0;
}