4 ms·
Even in cases like that it's uncommon for the object to actually take up a lot of stack space. Since member variable's sizes have to be known at compile time i
by bmm6o 12y ago
Even in cases like that it's uncommon for the object to actually take up a lot of stack space. Since member variable's sizes have to be known at compile time it only applies to fixed-size (or parametrized) buffers.
- vodik 12y agoAs far as I know, using `new` or not has nothing to really do if it goes onto the stack or not. That's simply a common implementation details. What its really saying is if the lifetime is automatic or manual. Maybe I'm confusing C with C++ or just outright confused, but to my understanding, nothing says that: int foo[] = <massive amount of data>; actually has to live on the stack.
- EpicEng 12y agoWell, in practice, it's both. Sure, stacks and heaps are an implementation detail, but they're pervasive. You simply can't write int x[10000][10000]; and expect it to not cause a stack overflow in any real world implementation. It's an implementation detail you absolutely need to be aware of.
- bmm6o 12y ago> nothing says that [...] actually has to live on the stack. This might be possible in theory but I've never seen it in practice.