seriously... there's a differenceCode:
For any normal programmer, I don't think there would be a big difference.
And the advantages outweighs the disadvantages.
you've got no advantage in the case of variable-length arrays.
Automatic memory management (at the very least, it will delete the memory it allocates).
No manual handling of exceptions (you do eventually need to resize sometimes, right?).
Can holder larger arrays than stack allows.
>> seriously... there's a difference <<
I hardly think the difference between using the &buf versus buf is worth choosing a non-portable solution.
>> you've got no advantage in the case of variable-length arrays.
Honestly I was introduced to variable-lengths in this thread. So I'm not quite sure where it comes from. But portability won't be an issue if the future holds to this standard.
>> Are we discussing the C++ extension or the C99 variable-arrays here?
Does it matter? Obviously we're talking about C++ since we're on the C++ board and comparing to vector. Memory management is an advantage of vector over new/delete. Portability is an advantage of vector over VLAs.
>> But portability won't be an issue if the future holds to this standard.
I'm not sure if they will be included in the C++ standard since C++ has an alternative (vectors), so until they are implemented by VC++ and other compilers and until they are included in a standard draft or technical report they aren't portable enough.
all I'm getting at is inline variable length is preferable to any form of using new. vector included
>> all I'm getting at is inline variable length is preferable to any form of using new. vector included
I already mentioned the efficiency question, but that situation is relatively rare and if you don't have such a reason then the portable solution is better.
We're better off without it.
Its kinda funny. I worked several different coding teams in my career. Ada, C, C++, and Java. These people vary in their world view so wildly that it could drive you crazy. All of them are language bigots. All of them are WAY to stringent on their philosophy of proper coding. I've really come back around to a "to each his own" policy lately.
>> I've really come back around to a "to each his own" policy lately.
I'm generally ok with that. Especially for people who know what they're doing. But on a board that helps beginners learn the language I don't see the problem explaining the advantages and disadvantages of different options, especially when there is a clear rationale to prefer one over the other.
As you might have noticed, at the beginning of this conversation I asked if you knew of a good situation of when to use dynamic arrays. I asked because I know that there are many skilled programmers out there with different habits and situations that might have a scenario that I haven't heard before. It's important to be aware of the other possible solutions. But if there is logic behind one choice and not the other, it is important to make that distinction.
The push-back that I have on that is basically driven by my recent experience with Java people. They are really well versed on OOP and design patterns but when it comes to low-level stuff, they're monkeys. Sometimes C++ people fall that way too.
It is silly to think that every possible container class necessary must already exist in the standard library. Coming down against reinventing the wheel is one thing, assuming that all small building blocks are already invented is another. Didn't the patent office make such a claim half a century ago?