Solved

CArray or vector  which should I use?

Posted on 2004-04-23
2
660 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 87
Hibernate methods 2 58
Doc'in system (example?) BA 7 79
sum67 challenge 35 89
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…
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 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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

26 Experts available now in Live!

Get 1:1 Help Now