INT>矢量&lt之间的差异; V []和矢量<矢量<诠释> > V [英] Difference between vector <int> V[] and vector< vector<int> > V

查看:152
本文介绍了INT>矢量&lt之间的差异; V []和矢量<矢量<诠释> > V的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

矢量<&INT GT; V [] 矢量<矢量<诠释> > V 都是二维数组

不过是他们的的的区别,以及我们使用在不同的地方?请给一个简要的解释。

But what is the difference between their and where we use this in different place?? Please give a brief explanation.

推荐答案

矢量<&INT GT; V [] 的载体阵列

矢量<矢量<诠释> > V 向量向量

cplusplus.com ,

矢量是序列容器重新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> 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆