MFC:: CString & Serialize ::C++

kuphryn

Senior member
Jan 7, 2001
400
0
0
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
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126


<< As far as textchar data is concerned, is it perferrable to use CString over C++ STL? Is it possible to have view draw character from a string object instead of a CString object? >>


Functions for graphics and text output to screen (GDI) all have char* versions so CString is not required for that.



<< 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)? >>


Existing MFC or Win32 functions that accept or return BOOL might not be happy with bool instead, but I've never had reason to try it.

No idea about serialize, the MFC apps I work on tend to have database-style record updating so I've almost always bypassed the archiving classes.
 

Adrian Tung

Golden Member
Oct 10, 1999
1,370
1
0


<< 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)? >>


If I am not mistaken, most of these variables/types (i.e. NULL, BOOL, TRUE, FALSE, INT, etc) are just typedef's or #define's of the standard variables/types that you use, except for BOOL, which if I am not mistaken is an int.



<< 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? >>


I don't remember, but I don't think that they do. Check the MSDN for the class members of CArchive - then check out its overloaded operators >> and <<. If your data type is not supported, you can always still use the standard Read and Write methods of CArchive to handle your STL classes manually.


:)atwl
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
NULL is the same as 0, so why difference does it make? There is an advantage to using a NULL - you can change #define NULL to be anything you want. Not the case with 0. So the way I look at it, NULL is a lot better than 0.