Hi, I have been trying to use the following code:
VendingDisplay.h:
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include "VendingMachine.h"
class VendingDisplay {
VendingMachine vend;
public: VendingDisplay(VendingMachine);
VendingDisplay();
void DisplayMenu();
void GetUserInput(int);
int respondToUserInput(int);
void processOrder(int);
int processCorrectCash(float);
};
VendingDisplay.cpp:
#include <vector>
#include "VendingDisplay.h"
#include "VendingMachine.h"
#include "Cigarette.h"
//#include "VendingMachine.cpp"
VendingDisplay::VendingDisplay(VendingMachine v)
{
vend=v;
}
Which just wasn't compiling. (The error VS gave me was: error:no instance of overloaded function VendingDisplay::VendingDisplay matches the specified type"). After looking around for ages and trying to understand passing objects to constructors, I still couldn't work out what I was doing wrong. So I ended up just changing my VendingDisplay.h file to:
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include "VendingMachine.h"
class VendingDisplay {
VendingMachine vend;
public: VendingDisplay(VendingMachine v)
{
vend=v;
}
VendingDisplay();
void DisplayMenu();
void GetUserInput(int);
int respondToUserInput(int);
void processOrder(int);
int processCorrectCash(float);
};
Which is essentially just putting the constructor method within the class definition, and removing the constructor entirely from the VendingDisplay.cpp file, but this got rid of the error. I am just having trouble understanding what it is that I have actually done that's made the difference. If anyone can enlighten me on this I would be so grateful.