为什么在C ++中新的动态堆栈分配? [英] why new dynamic stack allocation in C++?
问题描述
我的意思是为什么我只能在C ++中在堆栈上分配const大小的东西?如果我想分配一个可变数量,我需要使用OS API(在我的情况下是Win32)。
谢谢,
汤姆。
What I mean is why can I only allocate const size stuff on the stack in C++? If I want to allocate a variable amount I need to use the OS API (Win32 in my case).
Thanks,
Tom.
推荐答案
" Tom" < BL ** @ blah.com>写道...
"Tom" <bl**@blah.com> wrote...
我的意思是为什么我只能在
What I mean is why can I only allocate const size stuff on the stack in
中分配const大小的东西?
C ++?如果我想分配一个可变数量,我需要使用OS API
(在我的情况下是Win32)。
你在说什么?请阅读FAQ 5.8。您可以在这里找到常见问题解答: http:/ /www.parashift.com/c++-faq-lite/
Victor
C++? If I want to allocate a variable amount I need to use the OS API
(Win32 in my case).
What are you talking about? Please read the FAQ 5.8. You can
find FAQ here: http://www.parashift.com/c++-faq-lite/
Victor
Tom写道:
我的意思是为什么我只能在C ++中在堆栈上分配const大小的东西?如果我想分配一个可变数量,我需要使用OS API(在我的情况下是Win32)。
谢谢,
Tom。
What I mean is why can I only allocate const size stuff on the stack in C++? If I want to allocate a variable amount I need to use the OS API (Win32 in my case).
Thanks,
Tom.
这就是拥有堆栈和堆的整个点!如果你想要
分配的空间,在编译时未知的数量,但在运行时已经知道
运行时间,那么你就可以使用堆。
Java是一样的。
不确定其他langs。
~S
That is the whole point os having a stack and a heap! If you want to
allocated space, of amounts unknown at compile time, but known at
runtime, then you use the heap.
Java is the same.
Not sure about other langs.
~S
" Shea Martin" < SM ***** @ arcis.com>在消息中写道
news:uZLyb.16132
"Shea Martin" <sm*****@arcis.com> wrote in message
news:uZLyb.16132
这篇关于为什么在C ++中新的动态堆栈分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!