Click here to Skip to main content
15,913,055 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 12:11
Mark Salsbery18-Jun-07 12:11 
GeneralRe: operator new and CObject Pin
Bram van Kampen18-Jun-07 14:45
Bram van Kampen18-Jun-07 14:45 
GeneralRe: operator new and CObject Pin
bob1697218-Jun-07 15:00
bob1697218-Jun-07 15:00 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 13:11
Mark Salsbery18-Jun-07 13:11 
GeneralRe: operator new and CObject Pin
bob1697218-Jun-07 15:08
bob1697218-Jun-07 15:08 
GeneralRe: operator new and CObject Pin
Mark Salsbery18-Jun-07 15:27
Mark Salsbery18-Jun-07 15:27 
GeneralRe: operator new and CObject Pin
Bram van Kampen19-Jun-07 14:27
Bram van Kampen19-Jun-07 14:27 
GeneralRe: operator new and CObject Pin
Mark Salsbery19-Jun-07 14:58
Mark Salsbery19-Jun-07 14:58 
It's actually Microsoft sample code. It worked well for my test because I could put a breakpoint
in the catch block and I could immediately see the exception class without knowing what I'd get.
In real-life, IMO, a catch(...) is pretty useless. How can you possibly know how to proceed
or if it's even safe to proceed after catching an unknown exception?

The CException class is an abstract base class that provides one interface to get an error
message. If there's a DWORD involved, it's in a derived class, and is generally added so one
has a better context to detect why the exception occurred. I'm not sure what the DWORD is you're
referring to Smile | :) The variables added by the MFC exception classes are well documented.
With new CException-derived classes, you're on your own to add what you want.

In real life, AFAIK, exceptions shouldn't be used for simple error handling. Returning an error
code is faster and simpler.

Constructors can't return error codes so throwing an exception is the only way to indicate
failure.

Using MFC, sometimes it's not a choice. The database classes are a good example. Those
exceptions must be handled, and generally it's safe to continue after handling them, and they
also provide detailed error information for logging and/or deciding how to proceed after they
occur.

Hmm, I'm rambling pointlessly Laugh | :laugh:
Mark






"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

QuestionQuery interface parameter Pin
_tasleem18-Jun-07 10:47
_tasleem18-Jun-07 10:47 
AnswerRe: Query interface parameter Pin
Mark Salsbery18-Jun-07 11:08
Mark Salsbery18-Jun-07 11:08 
GeneralRe: Query interface parameter Pin
_tasleem19-Jun-07 2:47
_tasleem19-Jun-07 2:47 
GeneralRe: Query interface parameter Pin
Mark Salsbery19-Jun-07 4:33
Mark Salsbery19-Jun-07 4:33 
GeneralRe: Query interface parameter Pin
_tasleem19-Jun-07 9:04
_tasleem19-Jun-07 9:04 
QuestionGDI+ documentation Pin
Force Code18-Jun-07 7:43
Force Code18-Jun-07 7:43 
AnswerRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 7:47
Mark Salsbery18-Jun-07 7:47 
GeneralRe: GDI+ documentation Pin
Force Code18-Jun-07 8:16
Force Code18-Jun-07 8:16 
GeneralRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 8:34
Mark Salsbery18-Jun-07 8:34 
GeneralRe: GDI+ documentation Pin
Force Code18-Jun-07 10:08
Force Code18-Jun-07 10:08 
GeneralRe: GDI+ documentation Pin
Mark Salsbery18-Jun-07 11:04
Mark Salsbery18-Jun-07 11:04 
QuestionHandling input and graphics in a game engine Pin
Cyrilix18-Jun-07 7:33
Cyrilix18-Jun-07 7:33 
AnswerRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 8:10
Force Code18-Jun-07 8:10 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 8:29
Cyrilix18-Jun-07 8:29 
GeneralRe: Handling input and graphics in a game engine [modified] Pin
Force Code18-Jun-07 8:51
Force Code18-Jun-07 8:51 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 9:01
Cyrilix18-Jun-07 9:01 
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 9:15
Force Code18-Jun-07 9:15 

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.