June 20th, 2006, 05:49 AM
[RESOLVED] MFC Collection Classes.
One of issues that bother me in 'Visual C++' forum is when somebody open a thread like for example "I've got a question about CArray/CList/CStringArray/etc..." and often this answer comes: "Why don't you use std::vector/std::list? It's more powerfull...".
I always said "although, theoretical there is nothing wrong, once you are using MFC, it's not a brilliant idea to mix another stuff (like STL) if it's not absolutely necessary... it makes the application harder to read, maintain, etc".
No way to convince everybody... "std::vector has copy ctor, CArray has not, std::list have sort and other cool methods which CList has not, and blah-blah..."
Well in an MFC real application, me personal, I don't remember a situation to be really necessary to directly sort a collection class elements. Most of these comes from a database and no sweat to add an "ORDER BY" to SQL statement.
Or are strings needed to be ordered in a listbox/combobox, then we have LBS_SORT/CBS_SORT styles.
Or need to sort columns in a listview control and have CListCtrl::SortItems.
And generally what sense has sorting (or copy ctors/assignment operators) for windows, GDI objects,...?
To make STL-in-MFC-mixers, speak now or be silent forever...
would be great if implement also in some MFC collection classes some features "borrowed" from STL. For sure CStringList::Sort, CStringArray::Sort, CUIntArray::Sort, CStringList::Unique, etc have sense and there is no sweat to be implemented.
Moreover, since STL has no "direct" method 'vector::sort', we'll see MFC it's more powerful .
And who knows, maybe a CAlgorithm class...
Last edited by ovidiucucu; June 20th, 2006 at 06:17 AM.
Click Here to Expand Forum to Full Width