graph.h
struct Edge {
int from;
int to;
int elabel;
unsigned int id;
Edge(): from(0), to(0), elabel(0), id(0) {};
};
What is the difference between vector<Edge> and vector<Edge*>? I know vector<Edge> is an array storing Edge objects, but what is the Edge* object?
The
Edge*type is a pointer-to-edge. So avector<Edge*>is a vector that stores pointers-to-edges.The vector itself doesn’t store the objects, only pointers to those objects. This means in particular that the pointed-to objects don’t get automatically deleted when the pointer’s lifetime ends.