identifier not found

Im coding a theater's seating chart and calculate the prices
but when I execute it it shows me error message which is
"Error 1 error C3861: 'getPrice': identifier not found"

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
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <fstream>

using namespace std;

void ticketPrice();

int main()
{

	const int ROW = 15;
	const int SEATS = 20;

	char avail = '*';
	char taken = '#';
	int choice,choiceRow,choiceSeat;

	char seats[ROW][SEATS];

	cout << "* Seats Available\n# Reserved Seats" << endl;
	cout << "Seats:  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19";
	for(int i = 0; i < ROW; i++)
	{
		cout << "\nROW" << setw(3) << i;
		for(int index = 0; index < SEATS; index++)
		{
			seats[i][index] = avail;
			cout << setw(3) << seats[i][index];
		}
	}
	cout << "\n\nMENU:\n1) Buy ticket\n2) Total sell and exit" << endl;
	cout << "Enter your choice :";
	cin >> choice;
	
	while(choice == 1)
	{
		cout << "Enter row: ";
		cin >> choiceRow;
		cout << "Enter seat: ";
		cin >> choiceSeat;

		if(seats[choiceRow][choiceSeat] = avail)
		{
			seats[choiceRow][choiceSeat] = taken;
		}

		cout << "* Seats Available\n# Reserved Seats" << endl;
		cout << "Seats:  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19";
		for(int i = 0; i < ROW; i++)
		{
			cout << "\nROW" << setw(3) << i;
			for(int index = 0; index < SEATS; index++)
			{
				cout << setw(3) << seats[i][index];
			}
		}
		cout << "\n\nMENU:\n1) Buy ticket\n2) Total sell and exit" << endl;
		cout << "Enter your choice :";
		cin >> choice;
	}
	if(choice ==2)
	{
		cout << "UPDATED SEATING CHART AND SALES INFO";
		cout << "* Seats Available\n# Reserved Seats" << endl;
		cout << "Seats:  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19";
		for(int i = 0; i < ROW; i++)
		{
			cout << "\nROW" << setw(3) << i;
			for(int index = 0; index < SEATS; index++)
			{
				cout << setw(3) << seats[i][index];
			}
		}
		int sold = 0;
		for(int i = 0; i < ROW; i++)
		{
			for(int index = 0; index < SEATS; index++)
			{
				if(seats[i][index] == taken)
				{
					sold++;
				}
			}
		}
		cout << "TOTAL TICKET SOLD : " << sold;

		getPrice(seats);
		
		cout << "TOTAL REVENUE : $ ";


	
	}
}

void getPrice(char seat[15][20])
{
	int prices[15][20];
	string fname = "prices.dat";
	ofstream outFile;
	outFile.open(fname.c_str());
	for(int i = 0; i < 15; i++)
	{
		for(int index = 0; index < 20; index++)
		{
			if(i < 4)
			{
				prices[i][index] = 5;
			}
			else if(i < 10)
			{
				prices[i][index] = 10;
			}
			else if(i < 15)
			{
				prices[i][index] = 5;
			}
		}
	}
	outFile << prices;
	for(int i = 0; i < 15; i++)
		{
			for(int index = 0; index < 20; index++)
			{
				cout << setw(3) << prices[i][index];
			}
		}
	return;
}
You need to declare your functions before calling them. Now you declared nonexistent "ticketPrice()" instead.
When you want to call some functions you need to tell the compiler that they exist and what they do (declare them that is). After you can inform the compiler how they do it (definition that is).

So you have the following options:
-either declare your function (void getPrice(char seat[15][20]);) before main() and let your code lay definition after main() (as you do)

-move your definition before main(). You don't need to declare your function now now.

-You can use a separate cpp file and include its header file inside your main.cpp file
thank you guys It was really helpful
and little bit different from java
Topic archived. No new replies allowed.