Re: about new and delete
Sam wrote:
In short, the main problem with your test was that you tested only a
single n which was not just small but very small (namely 10). Instead
your test should
Yeah -- just like OP's test program, where I suggested that he'd look at
std::list, instead. I must've missed the part where he was trying to
allocate memory for a million ints, and meticulously typing all of them
in from the keyboard.
Do you know what I find hilarious? First you argue how much more
efficient std::list is compared to std::vector, and then you argue that
efficiency is irrelevant because the original poster just wanted to
input a dozen of values by hand to his program.
So what is it? Efficiency is a reason to choose std::list in this
case, or it isn't? Try to decide already.
If efficiency is irrelevant, then you have to consider ease of usage
as the second most important feature. Which one is, in your opinion,
easier to use, std::list or std::vector? Suppose, that you want to, for
example, iterate through the elements in the container:
for(std::list<int>::iterator iter = values.begin();
iter != values.end(); ++iter)
...
vs.
for(size_t i = 0; i < values.size(); ++i)
...
Take your pick.