I am a bit confused about this both of these look same to me. Although it may happen that capacity and size may differ on different compilers. how it may differ. Its also sa
Let's say you have a bucket. At most, this bucket can hold 5 gallons of water, so its capacity is 5 gallons. It may have any amount of water between 0 and 5, inclusive. The amount of water currently in the bucket is, in vector terms, its size. So if this bucket is half filled, it has a size of 2.5 gallons.
If you try to add more water to a bucket and it would overflow, you need to find a bigger bucket. So you get a bucket with a larger capacity and dump the old bucket's contents into the new one, then add the new water.
Capacity: Maximum amount of stuff the Vector/bucket can hold. Size: Amount of stuff currently in the Vector/bucket.