Re: How can I use CArray efficiently?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"MrAsm" <mrasm@xxxxxxx> wrote in message
news:dr0i135rc2hpk0kvoma7lsd2vu4md6gp20@xxxxxxxxxx
maybe the std::vector is better designed than CArray.
You might consider using it.

std::vector is easy to use (consider that I'm not in the set of C++
template-gurus :) so, if I'm telling you that std::vector is easy, it
really is :)


On the contrary, I find STL collections to be very non-intuitive as compared
to the MFC ones.



with std::vector you have two concepts:

- capacity
- size

capacity >= size


The capacity is set in CArray::SetSize(). But CArray::GetSize(), and the
newly added method CArray::GetCount(), report the actual number of elements
added, not the value you set.

In addition, CArray::SetSize() has a second nGrowBy parameter which lets you
specify how many elements are added in case you go beyonod the initial
number reserved by the first parameter. I don't see anything like that in
STL.

-- David


.