MFC:: CString & Serialize ::C++

Status
Not open for further replies.
Hello.

I am very familiar with C++ STL including the containers string and stringstream. When I learned of CString and other MFC data structure and mutator when I began learning MFC from Prosise's book (chapter 6).

I am learning MFC so that I can design and implement Windows 32bit programming using C++. Ultimate, as far as textchar data is concerned, is it perferrable to use CString over C++ STL (string, vector, list, etc.)? Is it possible to have view draw character from a string object instead of a CString object?

Lastly, does the default implementation for serialize work for C++ STL (string, vecto, list, etc.)? Does the STL container have to transfer data to a CString object first?

One last issue involving NULL. Microsoft seems to like using NULL over '0', which Deitel & Deitel recommend (I highly recommend their C++ How to Program). I do not use NULL term at all in my programs. I use '0'. When using core C++ program I have been working on into MFC, is it a necessity to change from '0' to NULL, bool to BOOL, true to TRUE, etc. for *all* code (even non MFC)?

Thanks,
Kuphryn
 
CString is going to be nicer if you need to interface with the Win32 API, especially for the functions that have MFC wrappers. It's also going to be nicer within MFC. In other cases, STL containers are probably going to be better if you have some STL experience). In simpler terms: CString's strong point is that it's well integrated with the other classes/functions from MS.

You can use NULL or 0, it doesn't matter. NULL is usually defined as 0, or (void*)0.

However, BOOL isn't bool. BOOL is a typedef to unsigned char (IIRC). It's a leftover from days when bool wasn't yet in C++. It also guarantees consistent size of the representation. You can usually use the C++ bool all over the place and not worry about it too much. Or you can use BOOL and not worry too much either (there is a very slight performance penalty under some circumstances). true/false go with bool, TRUE/FALSE with BOOL. They can usually be mixed without problems though.

As for non-MFC code, you do whatever you like.
 
Status
Not open for further replies.