In your
CashRegister
class you are trying to instantiate an
Inventory
object with the statement:
Inventory obj;
But in your
Inventory
class the only constructor for it is
Inventory(int q, double c)
So the two do not match. It would be better to declare the object in the
CashRegister
as a pointer, so you can pass the created object in your
CashRegister
constructor call in
main
.
class CashRegister
{
private:
Inventory* obj;
int item, quantity;
double total;
public:
CashRegister(Inventory* object, int i, int q){
int main()
{
Inventory i(10, 11.5);
int item, quantity;
cout<<"Enter item and quantity:\n";
cin>>item>>quantity;
CashRegister c(&i, item, quantity);
Note: The name
object
is often a reserved word or class name in OOP languages, so it is best avoided as a variable name.