bft question

i got a question about the BFT function.
here is my code where the cityMap is a container and visited is a vector
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
void Map::breadthFirstTraversal(Nodes t){

	for(int i = 0 ; i< cityMap.size(); i++)
	{

	visited[i] = 0;
	}
	queue <int> q;
	q.push(t);
	
	while(!q.empty())
	{
		int s = q.front();
		q.pop();
		visited[s] = 1;
		cout<<s<<endl;
		
		for(int i = 0; i<=q.size(); i++)
		{
			if(visited[i] == 0)
			{
				q.push(i);
				visited[i] = 1;
			}		
		}
	}
}


when i compile it return error shows that
 no matching function for call to ‘std::queue<int, std::deque<int, std::allocator<int> > >::push(Nodes&)’


thanks for people who helping me
closed account (zwA4jE8b)
your queue holds ints but you are pushing Nodes
thanks , but another issue happen, in line 13 is create a int the store the first element of queue, but compiler said can not convert Nodes to int, how can i solve this problem.
Same thing s holts int but you are trying to assign it to nodes
Post the class nodes and queue can help
closed account (zwA4jE8b)
if the node is a structure like
1
2
3
4
5
struct Noce
{
   int data;
   string stuff;
};


then you can use something like
int s = q.front()->data;

the -> references the member 'data' that is stored in the node.
Topic archived. No new replies allowed.