Click here to Skip to main content
15,911,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ Exceptions Pin
Zdeslav Vojkovic4-Jan-06 0:41
Zdeslav Vojkovic4-Jan-06 0:41 
GeneralRe: C++ Exceptions Pin
Chintoo7234-Jan-06 1:17
Chintoo7234-Jan-06 1:17 
GeneralRe: C++ Exceptions Pin
Zdeslav Vojkovic4-Jan-06 2:02
Zdeslav Vojkovic4-Jan-06 2:02 
Britley wrote:
The example[^] here uses a pointer to the exception object, whereas you are using a reference. What is correct?

if an exception is allocated on the heap (using 'new' operator), it must be caught through a pointer. however, this is not a good practice because it is not obvious to the client code how to handle it, and it complicates the deleting of the allocated exception instance (who will call delete on it). exceptions shoud be stack allocated, thrown, and caught by reference. please note that the example is for an MFC client, and MFC implements somewhat specific idiom, where exceptions are allocated on the heap and you have to call Delete() method of the CException class to destroy the instance.

Britley wrote:
Does this work like this:


no, because 5 is an int, not a long, but this does:
try {<br />
throw 5L;<br />
}catch(long x) {<br />
printf("%d", x);<br />
}


Britley wrote:
Can you tell me how you would obtain the exception info when using Microsoft Visual C++?


when you catch exception with (...) you can't do that. anyway, in this case you should always rethrow the exception, because it is not possible to correctly handle an exception without knowing its type. you can retrieve some exception info, but all the ways i know are OS specific, and not supported by standard c++. for more details, look here:
http://www.codeproject.com/cpp/exceptionhandler.asp
http://www.codeproject.com/debug/XCrashReportPt2.asp
and lots of other exception handling articles on codeproject

what you can do is to catch specific exceptions. example:
catch(exception& e)
this will catch all the exceptions of type 'exception' and of all types derived from it . exceptions are usually modelled in hierarchies, so you can handle multiple exception types in one handler.
GeneralRe: C++ Exceptions Pin
Chintoo7234-Jan-06 2:37
Chintoo7234-Jan-06 2:37 
GeneralRe: C++ Exceptions Pin
Zdeslav Vojkovic4-Jan-06 3:38
Zdeslav Vojkovic4-Jan-06 3:38 
GeneralRe: C++ Exceptions Pin
Chintoo7234-Jan-06 3:45
Chintoo7234-Jan-06 3:45 
GeneralRe: C++ Exceptions Pin
Zdeslav Vojkovic4-Jan-06 3:54
Zdeslav Vojkovic4-Jan-06 3:54 
GeneralRe: C++ Exceptions Pin
markkuk4-Jan-06 12:49
markkuk4-Jan-06 12:49 
GeneralRe: C++ Exceptions Pin
Jared Parsons4-Jan-06 5:38
Jared Parsons4-Jan-06 5:38 
AnswerRe: C++ Exceptions Pin
<color>Aljechin 4-Jan-06 0:45
<color>Aljechin 4-Jan-06 0:45 
GeneralRe: C++ Exceptions Pin
Zdeslav Vojkovic4-Jan-06 0:58
Zdeslav Vojkovic4-Jan-06 0:58 
Questionconnecting to server... Pin
Yuwraj4-Jan-06 0:00
Yuwraj4-Jan-06 0:00 
AnswerRe: connecting to server... Pin
sunit54-Jan-06 0:49
sunit54-Jan-06 0:49 
AnswerRe: connecting to server... Pin
Zdeslav Vojkovic4-Jan-06 0:49
Zdeslav Vojkovic4-Jan-06 0:49 
AnswerRe: connecting to server... Pin
ThatsAlok4-Jan-06 1:33
ThatsAlok4-Jan-06 1:33 
QuestionRe: connecting to server... Pin
David Crow4-Jan-06 4:33
David Crow4-Jan-06 4:33 
Questionhow can i check whether notepad.exe is running in taskmanager or not Pin
trinadh_t3-Jan-06 23:43
trinadh_t3-Jan-06 23:43 
AnswerRe: how can i check whether notepad.exe is running in taskmanager or not Pin
Owner drawn3-Jan-06 23:51
Owner drawn3-Jan-06 23:51 
GeneralRe: how can i check whether notepad.exe is running in taskmanager or not Pin
trinadh_t4-Jan-06 0:06
trinadh_t4-Jan-06 0:06 
GeneralRe: how can i check whether notepad.exe is running in taskmanager or not Pin
Owner drawn4-Jan-06 0:13
Owner drawn4-Jan-06 0:13 
GeneralRe: how can i check whether notepad.exe is running in taskmanager or not Pin
<color>Aljechin 4-Jan-06 0:51
<color>Aljechin 4-Jan-06 0:51 
GeneralRe: how can i check whether notepad.exe is running in taskmanager or not Pin
vikas amin4-Jan-06 4:20
vikas amin4-Jan-06 4:20 
GeneralRe: how can i check whether notepad.exe is running in taskmanager or not Pin
Dudi Avramov5-Jan-06 0:46
Dudi Avramov5-Jan-06 0:46 
QuestionRe: how can i check whether notepad.exe is running in taskmanager or not Pin
David Crow9-Jan-06 4:23
David Crow9-Jan-06 4:23 
QuestionSynchronize time Pin
Le Sourcier3-Jan-06 23:16
Le Sourcier3-Jan-06 23:16 

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.