I am new to this how do I fix these errors?

Here are the two errors i am getting. Now I know it has to be something completely stupid and simple but I am not seeing what is going wrong here.

Warning 1 warning C4273: 'rand' : inconsistent dll linkage 110
Error 2 error C2447: '{' : missing function header (old-style formal list? 111


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

#include "stdafx.h"
#include <iostream>
#include <ctime> 

using namespace std; 

class slotMachine {
private:
int wheelA;
int wheelB;
int wheelC;
double payOut; 
double moneyInMachine; 
double playersBalance; 
double gameCost; 
double moneyPaid; 
public:
slotMachine();
bool displayMenu(void);
bool pullHandle(void);
void spinWheel(int &);
double calculatePayout();
void insertCoin(double );
void displaySpinResults();
int Random(int, int);
void displayTotals();
}; 

int main(void) {

slotMachine mySlot; 

bool ok = true;
while (ok){
ok = mySlot.displayMenu();
}; 

return 0; 
} 

slotMachine::slotMachine () {

srand((int) time(0));
moneyInMachine = 100;
moneyPaid = 0;
payOut = 0;
wheelA = 0;
wheelB = 0;
wheelC = 0;
gameCost = 1;
} 

bool slotMachine::displayMenu(void){

char choice = 'Z'; 

bool continueGame = true; 

cout << "\n\n(E)nd, (P)ull, P(A)Y, (T)otals :"; 
cin >> choice; 

switch (choice) {
case 'e':
case 'E': 
continueGame = false; 
break; 
case 'a':
case 'A':  
double money; 
cout << "\nIt's a dollar a pull!\n" 
<< "Put money into the machine $"; 
cin >> money; 
insertCoin(money); 
break; 
case 'p':
case 'P': 
if (pullHandle()){ 
cout << endl << endl << endl; 
displaySpinResults(); 
cout << "Payout $" << calculatePayout(); 
} 
break;
case 't':
case 'T': 
displayTotals();
break;
}
return continueGame; 
} 

bool slotMachine::pullHandle(void){
double moneyInMachine = 25;
int wheelA = 1;
int wheelB = 2;
int wheelC = 3;

 playersBalance = moneyInMachine - moneyPaid;
 cout << "You have " << playersBalance << endl;

return true;

} 

void slotMachine::spinWheel(int &theWheel){

int wheelA = rand();
int wheelB = rand();
int wheelC = rand();
}
int rand();
{
int wheelA;
wheelA = 1 + rand() % (3 - 1 + 1 );
int wheelB;
wheelB = 1 + rand() % (3 - 1 + 1);
int wheelC;
wheelC = 1 + rand() % (3 - 1 + 1);
}

double slotMachine::calculatePayout(){
int jackPot = 1000;
int goodJob = 10;
int youLose = 5;
int wheelA = rand();
int wheelB = rand();
int wheelC = rand();

if (wheelA == wheelB && wheelA == wheelC)
{
	playersBalance = moneyInMachine + jackPot;
	cout << "Jackpot!!!  " << jackPot << endl;
	
}
 else if (wheelA == wheelB != wheelC || wheelA == wheelC != wheelB || wheelB == wheelC != wheelA)
{
	playersBalance = moneyInMachine + goodJob;
	cout << "Good Job  " << goodJob  << endl;
	
}

 else (wheelA != wheelB != wheelC || wheelA != wheelC != wheelB || wheelB != wheelC != wheelA);
{
	playersBalance = moneyInMachine - youLose;
	cout << "You Lose,Play Again" << endl;
	cout << " You have    " << playersBalance << endl;
	
}
return moneyInMachine;


} 

void slotMachine::insertCoin(double amount = 0){

int moneyInMachine = 25;
int moneyPaid = 0;

moneyInMachine = moneyPaid + moneyInMachine;

} 

void slotMachine::displaySpinResults()
{
cout << "[" << wheelA << "] " 
<< "[" << wheelB << "] " 
<< "[" << wheelC << "] \n\n" ; 
} 

void slotMachine::displayTotals(){

cout << "\nMoney in Machine $" << slotMachine::moneyInMachine << endl;
cout << "Pulls Left: " << slotMachine::gameCost / slotMachine::moneyPaid << endl << endl; 
} 

int slotMachine::Random(int lowerLimit, int upperLimit) {

 return 1 + rand() % (upperLimit - lowerLimit + 1); 
Well, first it would help in the error finding process if you format your code correctly. haha
Last edited on
What is line 111 supposed to mean?
I think he/she was trying to create a function but accidentally put a ; on the end.
If 111 is you trying to create a function, plz call the function something other than rand(randWheels maybe), especially if you're calling the built-in rand in the function
Your problem is in line 111 like the error says when you create a function you don't add a semicolon. The warning is because you named your function the same as a built in function and the computer wont know which to choose when you type rand(); Also the function you made doesn't return a value and you said it does. So you should change line 111 to:
void rand()
Ok I got that, yeah that was lack of sleep and stupid mistake. Thanks for the help on something so simple.
Topic archived. No new replies allowed.