For every stl container there is a MFC container available in visual c++.Which is better than the other one in what sense and what do you use?
I always use STL container is that wrong?
For every stl container there is a MFC container available in visual c++.Which is better than the other one in what sense and what do you use?
I always use STL container is that wrong?
I would always prefer the STL containers because of the portability.
MFC containers will nearly never be available on Linux.
Even if you don't plan to use you're code on Linux...you never know what the future brings.
People have pointed out portability of code as a reason to use STL, but there is a much better reason and one which is more in your self interest: Portability of skills and experience. In my opinion when you go looking for your next job having experience with STL on your resume will give you more opportunities. Why? STL effectively is part of standard C++ and if I was hiring I would assume that someone who knows STL could pick up the MFC containers fairly quickly, but I wouldn't necessarily make the opposite assumption if I was looking for someone with STL skills.
Even when they show you numbers that MFC containers are faster, can be exception-free and make free double-espresso: just close your eyes and use the DEL key (aka NO-LOCK-IN key).
You can do all that and more portably and in plugabble ways prop solutions can only dream of. STL all the way..
Can the MFC containers be used with standard algorithms in the STL?
MFC collection classes do have some advantages if you are working within confines of MFC land. E.g. you get things like serialization (if your container elements inherit from CObject or similar) and some debugging support for "free". MSDN has a breakdown of how to choose between different MFC collection types here.
As a default though, I would lean towards the STL classes.
"And frankly the team will give you the same answer. The MFC collection classes are only there for backwards compatibility. C++ has a standard for collection classes and that is the Standards C++ Library. There is no technical drawback for using any of the standard library in an MFC application.
We do not plan on making significant changes in this area.
Ronald Laeremans Acting Product Unit Manager Vsual C++ Team "
I use STL containers for many reasons: they're well tested, well documented, and well understood by people all over. They're also constantly being improved: look at all the new functionality added by Boost, and it's all backwards compatible. And if you really want to bend your mind, read Alexandrescu's Modern C++ Design: Generic Programming and Design Patterns Applied. Use of Boost and the STL is required to employ many of his techniques.
Something else to consider is the STL is "Standard" but the MFC is only "Microsoft". Any random generic C++ coder will likely understand STL, but only an old Microsoft coder will know MFC. Besides, Microsoft has pretty much abandoned MFC.