?
Solved

CArray or vector  which should I use?

Posted on 2004-04-23
2
Medium Priority
?
707 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

770 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