On Tue, 2012-05-15, Juha Nieminen wrote:
> wrote:
>> On Monday, May 14, 2012 3:06:24 PM UTC+1, bob wrote:
>>
>>> Okay. So, I have some code like so:
>>>
>>> void clear_directory(void)
>>> {
>>> char folder[100];
>>
>> this isn't very "C++ like". Why not use a std::string or
>> std::vector that will grow as necessary?
>
> Because if that function gets called a lot, then
> std::string and std::vector
> will be approximately a hundred times slower.
clear_directory() doesn't sound like such a function. This (avoiding
arrays with all their problems) is IMHO one of those things you should
do by default, and deviate only when there are good reasons.
(I also cannot take "approximately a hundred times slower" seriously.
You don't know what the function does, so you cannot possibly tell.)
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .