Help with Arrays: Airline Seating Program

Ok here I am again looking for some help. I'm at a loss and do not know why this console program is not working. Here is what it is SUPPOSED to do:
Allow the user to choose which section they would like to sit in.
Allow the user to choose which row and column they would like to sit.
Display a chart (array) showing which seat they have chosen then return to the main menu.
The array is supposed to be 13 rows designated by integers 1-13 (each section has particular rows) and 6 columns designated by characters A-F.
Here is the problem:
It will not allow the program to run because it says "error: 'void seating(char)' cannot convert argument 1 from 'char[13][6]' to char"
Please bypass me using using namespace std;
Here is 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
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
#include<iostream>
#include<iomanip>

using namespace std;

int section_menu();
void column_selection(char&);
void first_class(int&);
void business_class(int&);
void economy_class(int&);
void seating(char);
void show_seating(char, int, char);
int main()
{
	bool another = true;
	char column;
	int row, choice = 0;
	char chart[13][6];

	seating(chart);

	system("cls");
	cout << "*******************************************************\n";
	cout << "* Thank you for choosing Anthony's Flight Assignment. *\n";
	cout << "*  Best seats available for your flight, guaranteed,  *\n";
	cout << "*               or your money back!                   *\n";
	cout << "*******************************************************\n";
	system("pause");
	system("cls");

	while (another != false)
	{
		choice = section_menu();

		switch (choice)
		{
		case 1:
			first_class(row);
			column_selection(column);
			break;

		case 2:
			business_class(row);
			column_selection(column);
			break;

		case 3:
			economy_class(row);
			column_selection(column);
			break;

		case 4:
			show_seating(chart, row, column);

		case 5:
			another = false;
		}
	}
	return 0;
}

void seating(char chart[][6])
{
	for (int i = 0; i < 13; i++)
	for (int j = 0; j < 6; j++)
		chart[i][j] = '*';
}

int section_menu()
{
	int section;

	cout << "We have three sections to choose from, or you may exit.\n";
	cout << "\t 1 - First Class\n";
	cout << "\t 2 - Business Class\n";
	cout << "\t 3 - Economy Class\n";
	cout << "\t 4 - Show seating availability\n";
	cout << "\t 5 - Exit\n\n";
	cout << "Please select your section and press return. (1-4)\n";
	cin >> section;

	return section;
}

void first_class(int& row)
{
	cout << "*******************************************************\n";
	cout << "*                      First Class                    *\n";
	cout << "*******************************************************\n";

	cout << "Rows 1 and 2 are reserved for First Class seating.\n";
	cout << "Which row would you like?\n";
	cin >> row;

}

void business_class(int& row)
{
	cout << "*******************************************************\n";
	cout << "*                   Business Class                    *\n";
	cout << "*******************************************************\n";

	cout << "Rows 3 through 7 are reserved for Business Class seating.\n";
	cout << "Which row would you like?\n";
	cin >> row;


}

void economy_class(int& row)
{
	cout << "*******************************************************\n";
	cout << "*                     Economy Class                   *\n";
	cout << "*******************************************************\n";

	cout << "Rows 8 through 13 are reserved for Economy Class seating.\n";
	cout << "Which row would you like?\n";


}

void column_selection(char& column)
{
	cout << "Each row has 6 seats designated by letters A-F.\n";
	cout << "Which seat letter would you like to sit in?\n";
	cin >> column;

}

void show_seating(char chart[][6], int row, char column)
{
	int i, j;

	if (chart[row - 1][static_cast<int>(column - 65)] == 'X')
	{
		cout << "This seat already assigned. Choose another seat: " << endl;
		cin >> column;
		column = static_cast<char>(toupper(column));
	}
	chart[row - 1][static_cast<int>(column)-65] = 'X';

	cout << "* indicates that the seat is available; " << endl;
	cout << "X indicates that the seat is occupied. " << endl;
	cout << setw(12) << "A" << setw(6) << "B" << setw(6) << "C"
		<< setw(6) << "D" << setw(6) << "E" << setw(6) << "F" << endl;

	for (i = 0; i < 13; i++)
	{
		cout << left << setw(3) << "Row " << setw(2) << i + 1;
		for (j = 0; j < 6; j++)
		{
			cout << right << setw(6) << chart[i][j];
		}
		cout << endl;
	}
}
Last edited on
Thats because you are trying to pass a double dimension array of char to a function that accepts a single char.
Culprit is line 11. The forward declaration does not match the actual function on line 62
So would change the declaration on line 11 to void seating(char [][6]);
Ok. I figured that part out. Had to change the declaration to void seating(char chart[][6]); that actually makes the program run. Different issue. If I choose case 4 at the very beginning, the program freezes up, but if I make a seat selection then it will show the seating chart. Don't understand that. Secondly, the economy class looks exactly the same as the other two, but runs differently. The first two will run as follows:
Which Row?
// wait for user response
Which Column?
// wait for user response

The economy class runs as follows?
Which Row?
Which Column?
// wait for user response

I do not see what is different in the code to make it do this.
If I choose case 4 at the very beginning, the program freezes up, but if I make a seat selection then it will show the seating chart.


column isn't initialized - so if you call the show_seating function first there will be an uninitialized value at lines 134, 140.

Secondly, the economy class looks exactly the same as the other two, but runs differently.


Economy class - you don't have a cin >> row statement like you do in lines 93 and 105 in the other section functions.
Ah so it was not the same as the other two. Oops. Where would I initialize column though? I thought I was initializing it in main, but I'm not sure what value I should give it. The seating function initializes the '*' in all the proper places to start the chart out as if all seats are available. Then it runs through and shows the chart as if all seats are available after the user makes a seat selection.
Then it runs through and shows the chart as if all seats are available after the user makes a seat selection.

Disregard that. I'm a little slow. That portion works. Just do not know where to initialize the column. After that is fixed, then the program will run properly. I have class today in about half an hour so if I do not fix it by then, I'll run it by my instructor to see what he says.
Ok. This is what I did instead. I'm not even giving the option of looking at the seating chart before making a selection. Instead, I'm calling the show_seating function in each case, so after making a selection, it will show the chart of available seating with the users seat showing as reserved. Thanks again wildblue for pointing me in the right direction!
Topic archived. No new replies allowed.