intially creation of vector variable of size vector is 24 byte and when i push 15 element also size is not change and after i pop one element then size is not change
Cpp vector stl library
In your code, you are adding 10 elements, the loop iterates for 10 times. Also, when a vector is declared it is allocated some space that can hold elements larger in number than 10. Thus, the initial and final size of the vector is shown the same.
watch my program i am mention link and
i push 15 element but size of memory only 24 byte but according to me size of memory should be 4*15 byte after push the 15 element
Under the hood, every std:: vector is defined by three pointer of 8 bytes. Three pointers mentioned here are the begin vector, end vector and end of reserved memory for vector (i.e. vector’s capacity). That is the reason you were being shown size of 24. If you want to know the length of vector or the values it can hold then you should use v.size() or v.capacity().