本文介绍了为什么C ++不支持变长数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
用C
我只是好奇,有没有什么特别的原因C ++不允许变长数组?
I am just curious, is there any particular reason why C++ does not allow variable length arrays?
推荐答案
两个原因:
- C ++是基于C89(如1989年出版的C标准)。沃拉斯只在C99推出。
- C ++有
的std ::矢量<>
和一大堆其他的容器,这就是为什么我相信C ++决不会与沃拉斯打扰。它已经有了他们的时候沃拉斯被发明了C.
- C++ is based on C89 (the C standard as published in 1989). VLAs were only introduced in C99.
- C++ has
std::vector<>
and a whole bunch of other containers, which is why I believe that C++ will never bother with VLAs. It already had them when VLAs were invented for C.
这篇关于为什么C ++不支持变长数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!