Solved

CArray or vector  which should I use?

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 176
countEvens challenge 2 97
either24  challenge 19 95
building a service to accessed via telnet client, want colors ? 4 88
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

816 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

7 Experts available now in Live!

Get 1:1 Help Now