struct air_message
{
deque<int> path;
int dest_region;
int dest_airport;
int next_region;
int msg_from;
};
I have this structure. And I have this code
deque<int> p = graph->get_shortest_path(source_region, dest_region);
m->path = p;
At this line
m->path = p;
I am getting a segmentation fault error (‘m’ is a pointer of the air_message structure).
You need to examine the code that allocates
m. Your problem here isn’t with the deque itself, it’s becausemis not a valid pointer.For example, if the only code you have is:
then yes,
mwill not be valid.