answersLogoWhite

0


Best Answer

Although they share many of the same features, there are many differences. For instance, a list does not have an index operator [] while a vector does not have a merge method. If in doubt, simply look at the variable's declaration -- it will explicitly state whether the variable is a list or a vector (or indeed some other STL container), along with the type of data that it contains. Ultimately a vector is just an array, ideally suited to random access, whereas a list is ideally suited to sequential access.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

They are both standard library template classes that can be used as data containers. A vector is essentially an array template that allows constant time access to any element in the vector and can expand dynamically and more efficiently than a C-style array. There is no need to keep track of the size of the array as the length is encapsulated within the vector, thus passing vectors into functions is much easier and much safer than passing arrays. The template's methods and operators also provide a rich set of functions that make them easier to work with.

A list is essentially a doubly-linked list template that allows constant time access to the head or tail of the list, and includes all the functionality you would expect of a list, including sorting and traversal.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between vector and list in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the angle between vector a and vector b when mode of vector a plus vector b is equal to mode of vector a minus vector b?

90 degrees


What is an ordered list of data structure using c plus plus?

An ordered list of data in any programming language is simply a sorted array or list. In C++ this can either mean a sorted array, vector, list or forward list.


What is the difference between private stafford and plus student loans?

What is the difference between private stafford and plus student loans?


What difference between two nodes in c plus plus of single link list?

Their address. They may also have different values, and their sequence may matter, depending on the design of the algorithm.


When magnitude of vector a plus b is equal to the magnitude of vector a minus b then what is the angle between two vectors a and b?

2pi/3 radian or equivalent 120 degree


What is the difference between pointers in c and c plus plus?

Nothing.


What is the difference between be plus ing and get plus ing?

There are no such terms in C++.


C plus plus array-based lists?

If you mean an array where each element is a list, then the STL is your friend. To create an array of lists of any type T, use the following declaration: std::vector<std::list<T>> my_array_of_lists;


What is the difference between statements in c plus plus charconstp and char constp?

There is no difference. Both statements are invalid.


Vector A plus vector B equals 2i and vectorA-vectorB equals 4j then angle between vectorA and vectorB is?

I've got to assume that your ' i ' and your ' j ' are the same thing.Vector A = j3Vector B = -j1The angle between them is (pi).


What is the difference between Nike plus and Nike plus Active?

They have different names


What is the difference between plus 8 and -12?

-4