Error: "(variable) not initialized. this must be wrong!

I have a project to simulate a movie theater program that will track customers entering the theater between what line they are in or what movie/seats, etc.

One of my functions checks how many empty seats there are in a theater to check whether or not the party size being served is less than the amount of empty seats in the theater.

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
void tSize (queue<queue<myObject>> T, int eCount)
{
	string pName;
	eCount = 0;
	int Tsize;
	Tsize = T.size();
	queue<queue<myObject>> tQ;
	queue<myObject> temp;
	for (int x=0; x < Tsize; x++)
	{
		int y = T.front().size();
		for (int z=0; z < y; z++)
		{
			temp.push(T.front().front());
			T.front().pop();
			pName = temp.front().getString();
			if (pName == "empty")
				eCount++;
			T.front().push(temp.front());
			temp.pop();
		}
		while (!temp.empty())
		{
			T.front().push(temp.front());
			temp.pop();
		}
		T.push(T.front());
		T.pop();
	}
}


It keeps saying that my variable, eCount, is not being initialzed, when at the beginning of my 'int main()' i have -- int eCount;

Can anyone please give me advice?
Initialize means to give a value. It's complaining because you are using eCount in main before you have initialize it. My guess is that you are passing it as argument to tSize.

There is not much point having eCount as parameter in tSize because you never use the value that was passed in. If you are not interested in what value that is passed to the function you should make it a local variable instead.
i figured it out. it was because i wasn't actually passing any value into the function parameter.. i thought that whatever variable was passed into the function, when the function completes, the variable is then changed to the value calculated inside the function...

Since that is not the case, how would I be able to get the global eCount value to change as a result of the function being performed??
Nevermind, it seems that after hours of tweaking this code, as soon as I post looking for help, I figure it out on my own.

Need to pass variable by reference. *facepalm*
Topic archived. No new replies allowed.