【发布时间】:2018-10-30 04:39:30
【问题描述】:
这两种我都试过了,看不出区别
vector<int >a(n) and vector<int >a[n]
请有人解释一下。谢谢
【问题讨论】:
-
你想做什么?
-
使用STL实现整数数组
-
对于固定大小的数组,试试
const size_t ARRAY_SIZE = 42; int a[ARRAY_SIZE]; -
@ThomasMatthews 在 C++11 及更高版本中,建议使用
std::array代替:std::array<int, ARRAY_SIZE> a;