I've been getting an error that says a class isn't declared when I try to pass it to a function. I got this error before, so I deleted the code and typed it out again and it worked. It's not working this time.
The program starts in main, then goes to mainFunctions, then switchForDestinations, then to slotMachineClass which is where it says lotterySystem hasn't been declared (this is just a test for a game I might make). Irrelevant stuff has been removed.
main.cpp:
int main(){
srand(time(0));
mainFunctions mainFunction;
mainFunction.startGame();
return 0;
}
mainFunctions.cpp:
lotterySystem lottery;
energySystem energy;
moneySystem money;
slotMachineClass slots;
void mainFunctions::startGame(){
doSwitchForDestinations();
}
void mainFunctions::doSwitchForDestinations(){
printText.printPossibleDestinations();
cout << endl;
cin >> possibleDestinationChoice;
cout << endl;
switch(possibleDestinationChoice){
case 7:
switchDestinations.switchCaseSeven(lottery, money, energy, slots);
break;
}
switchfordestinations:
mainFunctions mainFunction;
void switchForDestinations::switchCaseSeven(lotterySystem& a, moneySystem& b, energySystem& c, slotMachineClass& d){
int destinationChoice;
cin >> destinationChoice;
cout << endl;
switch(destinationChoice){
case 1:
a.playLottery(a, b, c, d);
case 2:
d.playSlots(a, b, c, d);
case 3:
mainFunction.doSwitchForDestinations();
}
}
slotMachineClass:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include "energySystem.h"
#include "healthSystem.h"
#include "intelligenceSystem.h"
#include "printingText.h"
#include "experienceSystem.h"
#include "switchForDestinations.h"
#include "moneySystem.h"
#include "attackSystem.h"
#include "houseSystem.h"
#include "mainFunctions.h"
#include "gameSaving.h"
#include "lotterySystem.h"
#include "slotMachineClass.h"
using namespace std;
switchForDestinations switchDestinations3;
void slotMachineClass::playSlots(lotterySystem& d, moneySystem& a, energySystem& b, slotMachineClass& c){
//stuff
}
slotMachineClass.h:
#ifndef SLOTMACHINECLASS_H
#define SLOTMACHINECLASS_H
class slotMachineClass{
public:
int switchToMoney(int x);
void playSlots(moneySystem& a, energySystem& b, slotMachineClass& c, lotterySystem &d); //error: 'lotterySystem' has not been declared.
};
#endif // SLOTMACHINECLASS_H