C ++中的数组和列表

时间:2014-10-29 20:13:57

标签: c++ arrays list dynamic-arrays

您如何在C ++中开发以下类型的列表?

一个。列表的大小在编译时是已知的?

湾列表的大小在运行时确定一次,但之后是固定的吗?

℃。列表的大小必须在运行时更改,并且不允许使用 载体

3 个答案:

答案 0 :(得分:1)

  

您如何在C ++中开发以下类型的列表?

     

一个。列表的大小在编译时是已知的?

使用std::array


  

湾列表的大小在运行时确定一次,但之后是固定的吗?

使用std::vector


  

℃。列表的大小必须在运行时可以更改,并且不允许使用向量?

辞职,但如果您在辞职后有合同义务工作一段时间,请使用std::deque

答案 1 :(得分:0)

答案 2 :(得分:0)

a. The list’s size is known at compile time?任何普通的静态数组。

b. The list’s size is determined once at runtime but it is fixed thereafter?动态数组。使用变量作为大小进行初始化。

c. The list’s size must be changeable during runtime and you are not allowed to use vectors?我猜是一个arraylist或链表或其他任何行。