Homework help c++ Structs

This is my code for homework. I am doing a lot of stuff wrong but don't know exactly what. Any suggestions?

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <iostream>
using namespace std;

const MAX = 4;


// STRUCT DECLARATION
struct Airplanes
{
  string airline[MAX];
  string arrivingFrom[MAX];
};
// END STRUCT DECLARATION

//FUNCTIONS
  string  addNewArrival(string); //Organizes new plane to last place in array 
  bool newArrival(int totalArrivals[MAX]);
  bool fullTerminal(int totalArrivals[MAX]); //Test if there are new arrivles or if full

//MAIN BEGINS
int main()
{
Airplanes air;
int totalArrivals[MAX];
int addingNewArrival;
bool newArrivals;
bool full;
int i;

//START SETTING DEFAULTS
for(i = 0; i < MAX; i++)
{
 totalArrivals[i] = 0;
}

for(i = 0; i < MAX; i++)
{
 air.airline[i] = "";
 air.arrivingFrom[i] = "";
}
//END SETTING DEFAULT

newArrivals = newArrival(totalArrivals[]); 
if(newArrivals == true)
{
 cout << "There are no new Arrivals" << endl;
}
   else
   {
    cout << "There are new arrivals" << endl;
   }

addingNewArrival = addNewArrival(totalArrivals[]);
newArrivals = newArrival(totalArrivals[]);
cout << "newArrivals" << endl;

full = fullTerminal(totalArrivals[]);
if(full == true)
{
cout << "The terminal is full" << endl;
}
else
{
 cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}

air.airline[2] = "Air Canada";
air.airline[3] = "Delta";
air.arrivingFrom[2] = "Toronto";
air.arrivingFrom[3] = "Minneapolis";

addingNewArrival = addNewArrival(int totalArrivals[MAX]);
newArrival = newArrivals(totalArrival[]);
if(newArrival == true)
{
 cout << "There are new arrivals" << endl;
}
else
{
 cout << "There are no new arrivals" << endl;
}

full = fullTerminal(totalArrivals[MAX])
if(full == true)
{
 cout << "The terminal is full" << endl;
}
else
{
cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}


}
//MAIN ENDS




string addNewArrival(int totalArrivals[MAX])
{
int i;
int count =0;
air.airline[0] = "WestJet";
air.arrivingFrom[0] = "Calgary";
air.airline[1] = "United";
air.arrivingFrom[1] = "Chicago";

for(i = 0; i < MAX; i++)
{
 if(air.airline[i] != "")
 {
  count ++;
 }
}

while(i <= count)
{
 if(totalArrivals[i] ==0)
 {
  totalArrivals[i] = totalArrivals[i] + 1;
 }
}
}


bool newArrival(int totalArrivals[MAX])
{

int count;
int i

for(i = 0; i < MAX; i++)
{
 if(totalArrivals[i] ==0)
 {
 count ++
 }
}

 if(count == 4)
 {
  return true;
 }
   else
   {  
    return false;
   }
}


bool fullTerminal(int totalArrivals[MAX])
{

int count;

 for(i = 0; i < MAX; i ++)
 {
  if(totalArrivals[i] >0)
  {
   count ++;
  }
 }

 if(count == 4)
 {
  return true;
 }
  else
  {
  return false;
  }
}
What does it do that you don't want to, and what does it not do that you do want it to? Without knowing what you're trying to do, it's very hard to tell you how to fix it.
I'm getting like 20+ errors. I must be passing things wrong and defining stuff wrong. But I'm not really sure what exactly is wrong? It must be structured wrong.
Post the errors son.
After some fixing..

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include <iostream>
using namespace std;

const MAX = 4;


// STRUCT DECLARATION
struct Airplanes
{
  string airline[MAX];
  string arrivingFrom[MAX];
};
// END STRUCT DECLARATION

//FUNCTIONS
  string  addNewArrival(string); //Organizes new plane to last place in array 
  bool newArrival(int totalArrivals[]);
  bool fullTerminal(int totalArrivals[]); //Test if there are new arrivles or if full

//MAIN BEGINS
int main()
{
Airplanes air;
int totalArrivals[MAX];
int addingNewArrival;
int x;
bool newArrivals = false;
bool full = false;
int i;

//START SETTING DEFAULTS
for(i = 0; i < MAX; i++)
{
 totalArrivals[i] = 0;
}

for(i = 0; i < MAX; i++)
{
 air.airline[i] = "";
 air.arrivingFrom[i] = "";
}
//END SETTING DEFAULT

newArrivals = newArrival(totalArrivals[]); 
if(newArrivals == true)
{
 cout << "There are no new Arrivals" << endl;
}
   else
   {
    cout << "There are new arrivals" << endl;
   }

addingNewArrival = addNewArrival();
newArrivals = newArrival(totalArrivals[]);
cout << "newArrivals" << endl;

full = fullTerminal(totalArrivals[]);
if(full == true)
{
cout << "The terminal is full" << endl;
}
else
{
 cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}

air.airline[2] = "Air Canada";
air.airline[3] = "Delta";
air.arrivingFrom[2] = "Toronto";
air.arrivingFrom[3] = "Minneapolis";

addingNewArrival = addNewArrival(int totalArrivals[MAX]);
newArrival = newArrivals(totalArrival[]);
if(newArrival == true)
{
 cout << "There are new arrivals" << endl;
}
else
{
 cout << "There are no new arrivals" << endl;
}

full = fullTerminal(totalArrivals[MAX]);
if(full == true)
{
 cout << "The terminal is full" << endl;
}
else
{
cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}


}
//MAIN ENDS




string addNewArrival(int totalArrivals[])
{
int i;
int count =0;
air.airline[0] = "WestJet";
air.arrivingFrom[0] = "Calgary";
air.airline[1] = "United";
air.arrivingFrom[1] = "Chicago";

for(i = 0; i < MAX; i++)
{
 if(air.airline[i] != "")
 {
  count ++;
 }
}

while(i <= count)
{
 if(totalArrivals[i] ==0)
 {
  totalArrivals[i] = totalArrivals[i] + 1;
 }
}
}


bool newArrival(int totalArrivals[])
{

int count;
int i

for(i = 0; i < MAX; i++)
{
 if(totalArrivals[i] ==0)
 {
 count ++
 }
}

 if(count == 4)
 {
  return true;
 }
   else
   {  
    return false;
   }
}


bool fullTerminal(int totalArrivals[])
{

int count;

 for(i = 0; i < MAX; i ++)
 {
  if(totalArrivals[i] >0)
  {
   count ++;
  }
 }

 if(count == 4)
 {
  return true;
 }
  else
  {
  return false;
  }
}


ERRORS:

"A2BJ.cpp", line 55: Error: Operand expected instead of "]".
"A2BJ.cpp", line 55: Error: Formal argument totalArrivals of type int* in call to newArrival(int*) is being passed int.
"A2BJ.cpp", line 65: Error: Too few arguments in call to "addNewArrival(std::basic_string<char, std::char_traits<char>, std::allocator<char>>)".
"A2BJ.cpp", line 66: Error: Operand expected instead of "]".
"A2BJ.cpp", line 66: Error: Formal argument totalArrivals of type int* in call to newArrival(int*) is being passed int.
"A2BJ.cpp", line 69: Error: Operand expected instead of "]".
"A2BJ.cpp", line 69: Error: Formal argument totalArrivals of type int* in call to fullTerminal(int*) is being passed int.
"A2BJ.cpp", line 102: Error: Badly formed expression.
"A2BJ.cpp", line 103: Error: totalArrival is not defined.
"A2BJ.cpp", line 103: Error: Operand expected instead of "]".
"A2BJ.cpp", line 103: Error: Only a function may be called.
"A2BJ.cpp", line 104: Error: The operation "bool(*)(int*) == bool" is illegal.
"A2BJ.cpp", line 113: Error: Formal argument totalArrivals of type int* in call to fullTerminal(int*) is being passed int.
"A2BJ.cpp", line 152: Error: air is not defined.
"A2BJ.cpp", line 152: Error: Badly formed expression.
"A2BJ.cpp", line 153: Error: air is not defined.
"A2BJ.cpp", line 153: Error: Badly formed expression.
"A2BJ.cpp", line 154: Error: air is not defined.
"A2BJ.cpp", line 154: Error: Badly formed expression.
"A2BJ.cpp", line 155: Error: air is not defined.
"A2BJ.cpp", line 155: Error: Badly formed expression.
"A2BJ.cpp", line 159: Error: air is not defined.
"A2BJ.cpp", line 159: Error: Badly formed expression.
"A2BJ.cpp", line 172: Error: "addNewArrival(int*)" is expected to return a value.
"A2BJ.cpp", line 181: Error: Use ";" to terminate declarations.
Compilation aborted, too many Error messages.
okay ill take out as many as i can.

--"A2BJ.cpp", line 55: Error: Operand expected instead of "]".
I think this is because when passing an array as a parameter, you dont need the [].

next one is something about pointers, i still need to study pointers so no help there.

--"A2BJ.cpp", line 65: Error: Too few arguments in call to "addNewArrival(std::basic_string<char, std::char_traits<char>, std::allocator<char>>)".
This is easy, you arent passing in enough arguments

See the first error for all the other ones that expect an operand instead of "]"


uhh im used to working with classes so im not positive, but i think another problem your having is that your using variables that are declared in main. Either pass the variables to the functions making use of the "&" or declare the variables globally, or outside of main.


Thanks that helped a lot!
After some more fixing I only have 10 ERRORS!!! yay

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <iostream>
using namespace std;

const MAX = 4;


// STRUCT DECLARATION
struct Airplanes
{
  string airline[MAX];
  string arrivingFrom[MAX];
};
// END STRUCT DECLARATION

//FUNCTIONS
  string  addNewArrival(string); //Organizes new plane to last place in array 
  bool newArrival(int totalArrivals[]);
  bool fullTerminal(int totalArrivals[]); //Test if there are new arrivles or if full

//MAIN BEGINS
int main()
{
Airplanes air;
int totalArrivals[MAX];
int addingNewArrival;
int x;
bool newArrivals = false;
bool full = false;
int i;

//START SETTING DEFAULTS
for(i = 0; i < MAX; i++)
{
 totalArrivals[i] = 0;
}

for(i = 0; i < MAX; i++)
{
 air.airline[i] = "";
 air.arrivingFrom[i] = "";
}
//END SETTING DEFAULT

newArrivals = newArrival(totalArrivals); 
if(newArrivals == true)
{
 cout << "There are no new Arrivals" << endl;
}
   else
   {
    cout << "There are new arrivals" << endl;
   }

addingNewArrival = addNewArrival(totalArrivals);
newArrivals = newArrival(totalArrivals);
cout << "newArrivals" << endl;

full = fullTerminal(totalArrivals[]);
if(full == true)
{
cout << "The terminal is full" << endl;
}
else
{
 cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}

air.airline[2] = "Air Canada";
air.airline[3] = "Delta";
air.arrivingFrom[2] = "Toronto";
air.arrivingFrom[3] = "Minneapolis";

addingNewArrival = addNewArrival(int totalArrivals[MAX]);
newArrival = newArrivals(totalArrivals[]);
if(newArrival == true)
{
 cout << "There are new arrivals" << endl;
}
else
{
 cout << "There are no new arrivals" << endl;
}

full = fullTerminal(totalArrivals[MAX]);
if(full == true)
{
 cout << "The terminal is full" << endl;
}
else
{
cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}


}
//MAIN ENDS




string addNewArrival(int totalArrivals[])
{

Airplanes air;
int i;
int count =0;
air.airline[0] = "WestJet";
air.arrivingFrom[0] = "Calgary";
air.airline[1] = "United";
air.arrivingFrom[1] = "Chicago";

for(i = 0; i < MAX; i++)
{
 if(air.airline[i] != "")
 {
  count ++;
 }
}

while(i <= count)
{
 if(totalArrivals[i] ==0)
 {
  totalArrivals[i] = totalArrivals[i] + 1;
 }
}
}


bool newArrival(int totalArrivals[])
{

int count =0;
int i;

for(i = 0; i < MAX; i++)
{
 if(totalArrivals[i] ==0)
 {
 count ++;
 }
}

 if(count == 4)
 {
  return true;
 }
   else
   {  
    return false;
   }
}


bool fullTerminal(int totalArrivals[])
{

int count= 0;
int i;
 for(i = 0; i < MAX; i ++)
 {
  if(totalArrivals[i] >0)
  {
   count ++;
  }
 }

 if(count == 4)
 {
  return true;
 }
  else
  {
  return false;
  }
}


ERRORS:
"A2BJ.cpp", line 65: Error: Formal argument 1 of type std::basic_string<char, std::char_traits<char>, std::allocator<char>> in call to addNewArrival(std::basic_string<char, std::char_traits<char>, std::allocator<char>>) is being passed int*.
"A2BJ.cpp", line 65: Error: Cannot assign std::basic_string<char, std::char_traits<char>, std::allocator<char>> to int.
"A2BJ.cpp", line 69: Error: Operand expected instead of "]".
"A2BJ.cpp", line 69: Error: Formal argument totalArrivals of type int* in call to fullTerminal(int*) is being passed int.
"A2BJ.cpp", line 102: Error: Badly formed expression.
"A2BJ.cpp", line 103: Error: Operand expected instead of "]".
"A2BJ.cpp", line 103: Error: Only a function may be called.
"A2BJ.cpp", line 104: Error: The operation "bool(*)(int*) == bool" is illegal.
"A2BJ.cpp", line 113: Error: Formal argument totalArrivals of type int* in call to fullTerminal(int*) is being passed int.
"A2BJ.cpp", line 174: Error: "addNewArrival(int*)" is expected to return a value.

const MAX = 4;
What kind of object is MAX? The compiler needs to know.


full = fullTerminal(totalArrivals[]);
Stop doing this. There is no such object as totalArrivals[] so you cannot pass it to a function. There is something called totalArrivals.


addingNewArrival = addNewArrival(int totalArrivals[MAX]);

int totalArrivals[MAX]) is an attempt to create an array of type int. The compiler expects to find the name of the onject you want to pass into the function. This is just plain wrong.


newArrival = newArrivals(totalArrivals[]);
Stop doing this. There is no such object as totalArrivals[] so you cannot pass it to a function. There is something called totalArrivals. Also, newArrival is the name of function, newArrivals in an object. This kind of mix up is why it's a terrible idea to give your functions and objects almost identical names.


if(newArrival == true)
newArrival is a function name. How can you compare the name of a function to the value true? It makes no sense.

Last edited on
Thanks, that totally helped a lot! After fixing some more stuff, I have finally broke it down into 2 errors. All issues with addNewArrival.

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
.
.
.

.
.
.

*/

#include <iostream>
using namespace std;

const int MAX = 4;


// STRUCT DECLARATION
struct Airplanes
{
  string airline[MAX];
  string arrivingFrom[MAX];
};
// END STRUCT DECLARATION

//FUNCTIONS
  int  addNewArrival(string); //Organizes new plane to last place in array 
  bool newArrival(int totalArrivals[]);
  bool fullTerminal(int totalArrivals[]); //Test if there are new arrivles or if full

//MAIN BEGINS
int main()
{
Airplanes air;
int totalArrivals[MAX];
int addingNewArrival =0;
bool newArrivals = false;
bool full = false;
int i;

//START SETTING DEFAULTS
for(i = 0; i < MAX; i++)
{
 totalArrivals[i] = 0;
}

for(i = 0; i < MAX; i++)
{
 air.airline[i] = "";
 air.arrivingFrom[i] = "";
}
//END SETTING DEFAULT

newArrivals = newArrival(totalArrivals); 
if(newArrivals == true)
{
 cout << "There are no new Arrivals" << endl;
}
   else
   {
    cout << "There are new arrivals" << endl;
   }

addingNewArrival = addNewArrival(totalArrivals);
newArrivals = newArrival(totalArrivals);
cout << "newArrivals" << endl;

full = fullTerminal(totalArrivals);
if(full == true)
{
cout << "The terminal is full" << endl;
}
else
{
 cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}

air.airline[2] = "Air Canada";
air.airline[3] = "Delta";
air.arrivingFrom[2] = "Toronto";
air.arrivingFrom[3] = "Minneapolis";

addingNewArrival = addNewArrival(totalArrivals);
newArrivals = newArrival(totalArrivals);
if(newArrivals == true)
{
 cout << "There are new arrivals" << endl;
}
else
{
 cout << "There are no new arrivals" << endl;
}

full = fullTerminal(totalArrivals);
if(full == true)
{
 cout << "The terminal is full" << endl;
}
else
{
cout << "The terminal is not full" << endl;
}

cout << "Searching for Air Canada plane from Toronto " << endl;

for(i = 0; i < MAX; i++)
{
 if(air.arrivingFrom[i] == "Toronto")
 {
  cout << "There is a plane from toronto in" << endl;
 }
 if(air.airline[i] == "Air Canada")
 {
  cout << "It is from Air Canada" << endl;
 }
 else
 {
  cout << "It is not from Air Canada" << endl;
 }
}


}
//MAIN ENDS




int addNewArrival(int totalArrivals[])
{

Airplanes air;
int i;
int count =0;
air.airline[0] = "WestJet";
air.arrivingFrom[0] = "Calgary";
air.airline[1] = "United";
air.arrivingFrom[1] = "Chicago";

for(i = 0; i < MAX; i++)
{
 if(air.airline[i] != "")
 {
  count ++;
 }
}

while(i <= count)
{
 if(totalArrivals[i] ==0)
 {
  totalArrivals[i] = totalArrivals[i] + 1;
 }
}
return 1;
}


bool newArrival(int totalArrivals[])
{

int count =0;
int i;

for(i = 0; i < MAX; i++)
{
 if(totalArrivals[i] ==0)
 {
 count ++;
 }
}

 if(count == 4)
 {
  return true;
 }
   else
   {  
    return false;
   }
}


bool fullTerminal(int totalArrivals[])
{

int count= 0;
int i;
 for(i = 0; i < MAX; i ++)
 {
  if(totalArrivals[i] >0)
  {
   count ++;
  }
 }

 if(count == 4)
 {
  return true;
 }
  else
  {
  return false;
  }
}


ERRORS:

"A2BJ.cpp", line 64: Error: Formal argument 1 of type std::basic_string<char, std::char_traits<char>, std::allocator<char>> in call to addNewArrival(std::basic_string<char, std::char_traits<char>, std::allocator<char>>) is being passed int*.
"A2BJ.cpp", line 101: Error: Formal argument 1 of type std::basic_string<char, std::char_traits<char>, std::allocator<char>> in call to addNewArrival(std::basic_string<char, std::char_traits<char>, std::allocator<char>>) is being passed int*.
2 Error(s) detected.
Last edited on
When you pass an array like that, I believe it's in the form of a pointer to the first element of the array.
addingNewArrival = addNewArrival(totalArrivals);

What did you tell the compiler about this function? int addNewArrival(string);
So you told it that addNewArrival is a function that takes a string object.

What are you trying to pass it? totalArrivals.
What kind of object is totalArrivals? An int array.
Is that the same as a string? No.
Topic archived. No new replies allowed.