marphy-avatar

What is the difference between a Vector object and an array of objects?

"Hello to everybody, please explain vector object and an array of objects?"
over 13 years ago
0%

8 replies

over 13 years ago
electraxx-avatar
"a vector is a template class but not the array is. So obviously there are members to access the elements of the vector like, range checking, iterators, insertion/deletion, predicates, etc. Since it is a template class, the same implementation can be used for any type including pointers, objects/user defined types. Second, as said by others, vector automatically grow as we invoke push_back(), we can reserve additional space for elements, etc."
over 13 years ago
mcboon-avatar
"std::array is only a course edition in the classic Hundred raiment. Meaning it is size is predetermined on compile a serious amounts of it will be allocated like a solitary piece (E.gary. using living space about the push-down storage). The benefit they have will be a bit superior efficiency as there is simply no indirection between target and the arrayed facts. sexually transmitted disease::transmitter can be a little category comprising pointers to the lot. (When you apportion some sort of std::vector, it generally phone calls fresh.) There're a little bit more slowly to access due to the fact those pointers should be chased to access the arrayed data... But also in swap to the, they might be resized and so they only take a new superficial amount of pile infinite regardless of how huge they may be."