Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CArray or vector  which should I use?

Posted on 2004-04-23
2
Medium Priority
?
710 Views
Last Modified: 2013-11-20
I am new at MFC and have just started using CString and CStringArray.
I have seen comments saying it is better to use vector rather than CArray for other data types.
What do the experts say? Please explain you answer.
Get me started in the best direction.

0
Comment
Question by:MCofer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 500 total points
ID: 10902445
The MFC classes don't know anything about STL types. So if you are dealing with MFC functions that operate on MFC containers, I think you are better off using the MFC containers, you will save yourself a lot of trouble from converting back and forth.

As for which is better, this is largely a religious issue. Given that MFC is Windows-specific and therefore portability is not likely to be an issue, I would use whichever makes your coding with MFC easier.

For non-MFC coding, it makes no sense to drag in the MFC just to get some simple containers, and in that case I wouldn't hesitate to use STL. Although even now, there is still a lot of fear and loathing of STL, and some companies won't use it because of portability and performance issues that existed in the past.

0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10906271
Containers are not strong part of MFC. They don't perform well and have ugly syntax. Using of STL containers is a good decision. STL containers are generic and may contain any type of objects, including MFC objects. For example, std::vector<CString> - STL vector which contains MFC CString objects.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Loops Section Overview
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question