What should be the valid explanation of this? Here’s is the link to the code. With size mentioned in the vector push_back yields 0 as the output. But not when size is mentioned.
Why does push_back in vector yields 0 when size is mentioned?
when u do
vector v2(10)
then it means it has a vector already of 10 integer have 0 initialized now u can’t push back in it
u can simply do the updation like v[1]=5
the noemal template is
vectorv(size,value ) by default value is 0
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.