vector <int> v;
What exactly will the value of v be?
That is the syntax of default initialisation. Therefore the object will be in a default initialised state. For class types such as std::vector
, default initialisation calls the default constructor. An online reference describes the default constructor of vector thusly:
1) Default constructor. Constructs an empty container. If no allocator is supplied, allocator is obtained from a default-constructed instance.
Will it just be a pointer that points to the start of a memory block? Will its value be NULL?
A vector is not a pointer.
Among other members, a vector implementation does contain a pointer which may point to a buffer that the vector manages - you can get a copy of that pointer using the std::vector::data
member function. The state of the internal pointer of a default initialised vector is unspecified. Since an empty vector does not need a buffer, that pointer may be null - but is not required to be.