INT&GT;矢量&lt之间的差异; V []和矢量&lt;矢量&lt;诠释&GT; &GT; V [英] Difference between vector <int> V[] and vector< vector<int> > V
问题描述
矢量&lt;&INT GT; V []
和矢量&lt;矢量&lt;诠释&GT; &GT; V
都是二维数组。
不过是他们的的的区别,以及我们使用在不同的地方?请给一个简要的解释。
But what is the difference between their and where we use this in different place?? Please give a brief explanation.
推荐答案
矢量&lt;&INT GT; V []
是的载体阵列的
矢量&lt;矢量&lt;诠释&GT; &GT; V
是向量向量的
矢量是序列容器重新presenting阵列中,可以更改
大小。
Vectors are sequence containers representing arrays that can change in size.
就像数组,向量使用的连续的存储位置的他们
元素,这意味着它们的元素也可以用被访问
定期指向它的元素偏移和同样有效
在阵列。但是不像数组,其大小可动态变化,
其存储由容器自动处理。
Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.
TL; DR
当你想用的固定数量的工作 的std ::矢量
元素,你可以使用矢量&lt的; INT&GT; V []
。
When you want to work with a fixed number of std::vector
elements, you can use vector <int> V[]
.
当你想用的动态数组工作 的std ::矢量
,您可以用矢量&lt的;矢量&lt;诠释&GT; &GT; V
。
When you want to work with a dynamic array of std::vector
, you can use vector< vector<int> > V
.
这篇关于INT&GT;矢量&lt之间的差异; V []和矢量&lt;矢量&lt;诠释&GT; &GT; V的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!