C++ functions error

Hey guys, ive written this program for an assignment of mine, its a airline reservation system that allows a user to book seats within two classes, first and second. First class is seats 1-5, second class 6-10. Ive written a program that uses functions and im sure that ive missed something out because im getting this error:

(13) : error C3861: 'MainMenuDisplay': identifier not found
(18) : error C3861: 'FirstClass': identifier not found
p(22) : error C3861: 'SecondClass': identifier not found

heres my code :

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
#include<iostream>
using namespace std;
#define MAX_FIRSTposition 5
#define MAX_SECONDposition 10
int position, ans;
bool firstclass [5]= {0};
bool secondclass [5]= {0};


int main()
{
		
			MainMenuDisplay();
		cout<<"\tWhich class would you like?" << endl;
		cin>>ans;
		
			if (ans == 1)
				FirstClass( firstclass);
		
		
			if (ans == 2)
				SecondClass( firstclass ) ;
		
		
	return 0;
}

void MainMenuDisplay()
{
	cout <<"\t--Hello, welcome to AIRLINE RESERVATION--" << endl;
	cout <<"--Please select the following:" << endl;
	cout <<"--[1] For a First-class seat" << endl;
	cout <<"--[2] For a Second-class seat" << endl;
	cout <<"--[3] Quit program.\n\n" << endl;

}

void FirstClass( int firstclass[])
{
			char check ; 
			int count = 0 ;
			
			cout << "\t--Welcome to first class--" << endl;
			do
			{
			cout<<"\tPlease choose a seat"<< endl;
			cin >> position;
				if (position  >= MAX_FIRSTposition)
				{
					cout << "The seating arrangements for this class is 1-5, please pick again." << endl;					 
				}
			}
			while ( position   >= MAX_FIRSTposition);
			
			
			if (firstclass [position - 1] == 0) 
			{
				firstclass [position - 1] = 1;
				cout << "Your seat number is: " << position << endl;
			}
			else
			{
				cout << "This seat is already booked" << endl;
			}
			
			
			while(count < MAX_FIRSTposition ) 
			{
				if( firstclass[count] == 0)
					break;
					
				count++;

						
			};
			if( count >= MAX_FIRSTposition )
			cout<< "\tUnfortunately, the First class is now full." << endl;
}

void SecondClass( int firstclass[])
{
			char check ; 
			int count = 5 ;
			
			cout << "\t--Welcome to Second class--" << endl;
			do
			{
			cout<<"\tPlease choose a seat"<< endl;
			cin >> position;
				if ( (position  < MAX_FIRSTposition) && (position  >= MAX_SECONDposition) )
				{
					cout << "The seating arrangements for this class is 6-10, please pick again." << endl;					 
				}
			}
			while ( (position  < MAX_FIRSTposition) && (position  >= MAX_SECONDposition));
			
			
			if (firstclass [position - 1] == 0) 
			{
				firstclass [position - 1] = 1;
				cout << "Your seat number is: " << position << endl;
			}
			else
			{
				cout << "This seat is already booked" << endl;
			}
			
			
			while( (count > MAX_FIRSTposition ) && (count > MAX_SECONDposition)  ) 
			{
				if( firstclass[count] == 0)
					break;
					
				count++;

						
			};
			if( count >= MAX_SECONDposition )
			cout<< "\tUnfortunately, the First class is now full." << endl;
}


You need to forward declare functions. On next line below global variables write
1
2
3
void FirstClass( int firstclass[]);
void SecondClass( int firstclass[]);
void MainMenuDisplay();

Additional notes:
Using global variables is very bad programing experience. You will defiantly lose some marks for that.
Your code formating sucks. Use http://en.wikipedia.org/wiki/Off-side_rule . Personally, I put two spaces, not 4 as you see in that example.
And there are many other things wrong with the program.
I have only been doing this for 8 weeks so of course this will "suck". Thank-you for the help, ill delete the extra spaces.

Do you think you could help me with the rest of the errors?
Ortonas is correct, you need to prototype your functions before they're called. Prototyping means putting basically the same thing as a variable declaration before you use a variable. The only thing that you have to tell the compiler is what the functions look like, so in Ortonas' example, you see the prototypes with no function definition. These must be placed before the function in which the function call is used.

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void FirstClass(int firstclass[]); // Function prototype

int main(){
..
..
    FirstClass(firstclass); // Function call
..
}

void FirstClass(int firstclass[]){
..
..
..
} // Function definition 


As an aside, I program in the opposite direction. My int main() is always the last function that I put in the program; in fact, I try not to prototype if I can avoid it, instead putting all functions above where they are called, when possible. This is more of a personal technique, though, don't take it as c++ gospel.

Example:
1
2
3
4
5
6
7
8
9
10
11
12
void FirstClass(int firstclass[]){
..
..
..
} // Function definition

int main(){
..
..
    FirstClass(firstclass); // Function call
..
}
Ah, this was VERY helpful, thankyou alot for the tips and information. The only errors i am getting now is this:

(18) : error C2664: 'FirstClass' : cannot convert parameter 1 from 'bool [5]' to 'int []'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
(20) : error C2664: 'SecondClass' : cannot convert parameter 1 from 'bool [5]' to 'int []'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
That's because you're declaring firstclass and secondclass as:
1
2
bool firstclass [5]= {0}; // Boolean declaration
bool secondclass [5]= {0}; // Boolean declaration 

You are prototyping the function calls as:
1
2
void FirstClass(int firstclass[]); // Integer variable prototype
void SecondClass(int secondclass[]); // Integer variable prototype 


If the type of variable doesn't match what you are trying to use it as, you will get errors. So if you want to have them be bool, you have to use them as a bool throughout the program. Likewise, if you want to use them as int, you should define them as int. I would recommend simply defining them to however your intent is to use them, rather than changing your use of them to match the definition, but either way the definition and the use have to match.
Wow, such a small and simple mistake! Thankyou kind sir!
Topic archived. No new replies allowed.