Solved

CArray or vector  which should I use?

Posted on 2004-04-23
2
670 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
2 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 53
NotAlone Challenge 20 79
Execute multiple curl cmds with sleep and send output to file 10 88
firstChar challenge 13 107
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now