It depends... If you want a speedy processing go for array list If you want thread safety go for a vector
Yes. A vector is a variable-length array but constant-time random-access is guaranteed regardless of an array's length.
Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.
If the array does not have an initial size parameter, the array would be the size of the initialization vector, so you would not be able to store any data beyond the end of those elements without crashing your program or causing memory bugs. If there is a specified array size and the initialization vector is smaller than that size, then all remaining elements will be set to the value 0; it is not an error to not specify all elements in the initialization vector.
You simply instantiate the array for each type. That's the beauty of template (or generic) programming. vector<int> myIntArray; vector<double> myDoubleArray; vector<myClass> myClassArray; myDoubleArray.push_back(3.5); myDoubleArray.push_back(6.7); myDoubleArray.push_back(3.14159); The myDoubleArray (actually, it called a vector, which is the container type most closely like an array) now contains 3.5, 6.7, 3.14159, and you can easily use them naively, as in myDoubleArray[1] is equal to 6.7, etc. Of course, the power of STL containers is that you can use various algorithms on them, and you can create iterators to more easily traverse them, but this is enough to answer the question.
string, vector and array do not have a common base class. Overload your function to accept either a string, a vector or an array.
It depends... If you want a speedy processing go for array list If you want thread safety go for a vector
List is not sync'd as a vector is.
Vector class is defined inside util package this is differing form an array in a fashion that arrays size can not be changed during run time so as to have an object that might contain list of values and should facilitate programmer to extend or shrink the size of a data structure as and when required Vector should be used.
Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.
Yes. A vector is a variable-length array but constant-time random-access is guaranteed regardless of an array's length.
An array is not a derived data type at all. In order to be derived there has to be a base class and an array has no base class. Here is the basic declaration of the std::array template class from the <array> header file: template<class _Ty, size_t _Size> class array { // fixed size array of values // ... }; A vector, on the other hand, is derived (from the <vector> header file): template<class _Ty, class _Alloc = allocator<_Ty>> class vector : public _Vector_alloc<!is_empty<_Alloc>::value, _Vec_base_types<_Ty, _Alloc>> { // varying size array of values // ... };
Vector processor and Array processor are just the same thing, its a CPU design where instruction are set includes operations that can perform mathematical operations on multiple data elements simultaneously.
A horizontal array or a row vector.
Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.
If the array does not have an initial size parameter, the array would be the size of the initialization vector, so you would not be able to store any data beyond the end of those elements without crashing your program or causing memory bugs. If there is a specified array size and the initialization vector is smaller than that size, then all remaining elements will be set to the value 0; it is not an error to not specify all elements in the initialization vector.
The size of a vector cannot be fixed because a vector is a wrapper for a dynamic array where resizing occurs automatically (by virtue of the vector class). So, even if you reserved enough memory for n elements in advance, the vector will resize automatically as soon as you push more than n elements. A normal dynamic array does not resize automatically (you have to manually resize the array in order to accommodate more elements than you've allowed), and is therefore more suitable for a fixed size dynamic array. However, if you embed a vector in your own class wrapper (such as fixed_vector), you can reserve n elements in the vector via the constructor, and subsequently control how many elements are pushed onto the vector. Once n elements are pushed, any subsequent elements can be ignored, perhaps raising an exception for added safety.