This looks simple but I am confused: The way I create a vector of hundred, say, int
s is
std::vector<int> *pVect = new std::vector<int>(100);
However, looking at std::vector's documentation I see that its constructor is of the form
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
So, how does the previous one work? Does new
call the constructor with an initialization value obtained from the default constructor? If that is the case, would
std::vector<int, my_allocator> *pVect = new std::vector<int>(100, my_allocator);
where I pass my own allocator, also work?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With