There are a few things here.
First, you do not initialize the iterator, as others said:
list<vertex*>::iterator it = r_list->begin();
Do this and your code will be fine. But your code is performing poorly.
? : . delete r_list . (std::unique_ptr, std::shared_ptr, ++ 11, : boost::scoped_ptr boost::shared_ptr)
, :
list<vertex*> r_list;
list<vertex*>::iterator it = r_list->begin();
r_list.insert(it, pr);
, . push front() push back():
list<vertex*> r_list;
r_list.push_back(pr);
: , , - .
:
list<vertex*> r_list;
void some_function(void)
{
vertex r = {WHITE, NULL, NULL};
vertex *pr = &r;
r_list.push_back(pr);
}
:
list<vertex*> r_list;
void some_function(void)
{
vertex *r = new vertex;
r->color = WHITE;
r->distance = 0;
r->parent = 0;
r_list.push_back(r);
}
. , , , lsit delete . Boost Pointer Container Library.
, , , ( ):
list<vertex> r_list;
vertex r = {WHITE, NULL, NULL};
r_list.push_back(r);
, :
struct vertex
{
int color;
int distance;
char parent;
vertex(int _color, int _distance, char _parent) :
color(_color),
distance(_distance),
parent(_parent)
{
}
};
list<vertex> r_list;
r_list.push_back(vertex(WHITE, NULL, NULL));
( )
-, NULL . distance parent , 0 NULL:
vertex r = {WHITE, 0, 0};
-, constants, #define:
#define NUM_VERTICES 8
const int NumberVertices = 8;
, :
enum Color { WHITE, GRAY, BLACK };
, !