I dont know why i get this error. Can someone explain why i get this error for this constructor and a way to fix this?
Out-of-line definition of 'VendingMachine' does not match any declaration in 'VendingMachine'
class VendingMachine : public Item
{
private:
Item items[10]; //array of Item object
int quantities[10];
float cash;
float credit;
public:
VendingMachine(Item, int);
float insertDollar();
float insertQuarter();
void printMenu();
void selectItem();
float cancel();
void printReportToFile();
};
#endif /* vendingMachine_h */
---vendingMachine.cpp---
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
#include "vendingMachine.h"
VendingMachine::VendingMachine(Item array_items[], int array_quantities[])
//ERROR: I have the error above this line at the "::VendingMachine(" area
//Out-of-line definition of 'VendingMachine' does not match any declaration in 'VendingMachine'
{
for(int i = 0; i < 10; i++)
{
items[i] = array_items[i];
quantities[i] = array_quantities[i];
}
cash = 0.00;
credit = 0.00;
}
The constructor you declare in the header file takes a scalar Item and a scalar int.
The constructor you attempt to define in the implementation takes an array of Item and an array of int.
Scalars and arrays are different entities. This doesn't match and your compiler tells you so.