Click here to Skip to main content
16,005,037 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWinApp::OnFileNew Pin
Sam Hobbs8-Sep-00 9:29
Sam Hobbs8-Sep-00 9:29 
GeneralRe: CWinApp::OnFileNew Pin
nisse11-Sep-00 5:08
nisse11-Sep-00 5:08 
GeneralMAC Address Pin
Roger6-Sep-00 4:23
Roger6-Sep-00 4:23 
GeneralRe: MAC Address Pin
Paolo Messina6-Sep-00 9:51
professionalPaolo Messina6-Sep-00 9:51 
GeneralAdding Handlers for User-Defined Messages Pin
#realJSOP6-Sep-00 1:27
professional#realJSOP6-Sep-00 1:27 
Generalchange the windows opening screen Pin
thrivikram6-Sep-00 1:24
thrivikram6-Sep-00 1:24 
GeneralC++ Exception Pin
koteswara5-Sep-00 20:46
koteswara5-Sep-00 20:46 
GeneralRe: C++ Exception Pin
Pete Bassett5-Sep-00 22:50
Pete Bassett5-Sep-00 22:50 
Hi. This is from the MSDN.

CString::operator =
const CString& operator =( const CString& stringSrc );
throw( CMemoryException );

const CString& operator =( TCHAR ch );
throw( CMemoryException );

const CString& operator =( const unsigned char* psz );
throw( CMemoryException );

const CString& operator =( LPCWSTR lpsz );
throw( CMemoryException );

const CString& operator =( LPCSTR lpsz );
throw( CMemoryException );

Remarks

The CString assignment (=) operator reinitializes an existing CString object with new data. If the destination string (that is, the left side) is already large enough to store the new data, no new memory allocation is performed. You should be aware that memory exceptions may occur whenever you use the assignment operator because new storage is often allocated to hold the resulting CString object.

Example

The following example demonstrates the use of CString::operator =.

// example for CString::operator =
CString s1, s2; // Empty CString objects

s1 = "cat"; // s1 = "cat"
s2 = s1; // s1 and s2 each = "cat"
s1 = "the " + s1; // Or expressions
s1 = 'x'; // Or just individual characters

And heres what it says about CMemoryException.

A CMemoryException object represents an out-of-memory exception condition. No further qualification is necessary or possible. Memory exceptions are thrown automatically by new. If you write your own memory functions, using malloc, for example, then you are responsible for throwing memory exceptions.

So your catch should be something like this

try
{
// do the string stuff
}
catch(const CMemoryException e)
{
// do something with it
}
catch(...)
{
// just to catch any others that crop up.
// make sure you do somehing drastic if anything appears
// here because it SHOULD NOT HAPPEN.
}

Hope this helps. Pete
GeneralRe: C++ Exception Pin
Tim Deveaux6-Sep-00 6:23
Tim Deveaux6-Sep-00 6:23 
GeneralRe: C++ Exception Pin
Pete Bassett6-Sep-00 6:33
Pete Bassett6-Sep-00 6:33 
GeneralRe: C++ Exception Pin
Chris Losinger7-Sep-00 11:29
professionalChris Losinger7-Sep-00 11:29 
GeneralRe: C++ Exception Pin
Remus Lazar5-Sep-00 22:51
Remus Lazar5-Sep-00 22:51 
GeneralProblem in the release exe Pin
N.S.5-Sep-00 20:27
N.S.5-Sep-00 20:27 
GeneralRe: Problem in the release exe Pin
Remus Lazar5-Sep-00 23:00
Remus Lazar5-Sep-00 23:00 
GeneralRe: Problem in the release exe Pin
David Vest6-Sep-00 14:11
David Vest6-Sep-00 14:11 
GeneralRe: Problem in the release exe Pin
Sam Hobbs8-Sep-00 9:40
Sam Hobbs8-Sep-00 9:40 
GeneralHiding the Menu in a MFC Application Pin
Charles Rodericl5-Sep-00 18:02
sussCharles Rodericl5-Sep-00 18:02 
GeneralRe: Hiding the Menu in a MFC Application Pin
Remus Lazar5-Sep-00 23:07
Remus Lazar5-Sep-00 23:07 
GeneralChanging default icon for saved documents in SDI Pin
Savage5-Sep-00 13:58
Savage5-Sep-00 13:58 
GeneralRe: Changing default icon for saved documents in SDI Pin
Michael Dunn5-Sep-00 18:19
sitebuilderMichael Dunn5-Sep-00 18:19 
GeneralUnicode vs. ANSI string Pin
Member 117662575-Sep-00 11:57
Member 117662575-Sep-00 11:57 
GeneralRe: Unicode vs. ANSI string Pin
Serge Velikevitch15-Sep-00 11:11
sussSerge Velikevitch15-Sep-00 11:11 
GeneralBeginner Q: Viewing the contents of an array in the watch window Pin
Matthias Steinbart5-Sep-00 5:17
sussMatthias Steinbart5-Sep-00 5:17 
GeneralRe: Beginner Q: Viewing the contents of an array in the watch window Pin
arf5-Sep-00 6:00
arf5-Sep-00 6:00 
GeneralCFileDialog problems on Win2000 with read only files Pin
Ronald L. Russell Jr. (Ron)5-Sep-00 3:42
sussRonald L. Russell Jr. (Ron)5-Sep-00 3:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.