you don't initialize an empty vector field in your class, default constructor of vector suffices. You may however resize it in constructor if you know already the number of elements.
Graph(int NumberOfVertices):vertices(NumberOfVertices),
edges(0) { adjacency_list.resize(vertices)};
This is definitely incorrect:
adjacency_list(NULL) // this will evaluate to vector(0)
// and your vector has 0 size
probably you've confused the pointers that vector stores with the vector itself. Initializing class vector with NULL will evaluate to a vector with 0 size. There is no need to initialize an empty vector
instance which is a class member:
Default initialization is performed in three situations:
1) when a variable with automatic storage duration is declared with
no initializer
2) when an object with dynamic storage duration is created by a
new-expression without an initializer
3) when a base class or a non-static data member is not mentioned in
a constructor initializer list and that constructor is called. <<< aha
The effects of default initialization are:
If T is a class type, the default constructor is called to provide the
initial value for the new object.
If T is an array type, every element of the array is
default-initialized. Otherwise, nothing is done.
If T is a const-qualified type, it must be a class type with a
user-provided default constructor.