Click here to Skip to main content
15,886,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVB Active X on a VC++ dialog Pin
GayathriNaveen4-Jan-06 0:25
GayathriNaveen4-Jan-06 0:25 
Questionhow to copy values only from one com object (Interface) Pin
gpshadrach4-Jan-06 0:11
gpshadrach4-Jan-06 0:11 
AnswerRe: how to copy values only from one com object (Interface) Pin
Prakash Nadar4-Jan-06 0:34
Prakash Nadar4-Jan-06 0:34 
QuestionC++ Exceptions Pin
Chintoo7234-Jan-06 0:06
Chintoo7234-Jan-06 0:06 
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 
GeneralRe: C++ Exceptions Pin
Chintoo7234-Jan-06 2:37
Chintoo7234-Jan-06 2:37 
Thanks for the great information.

Zdeslav Vojkovic wrote:
if an exception is allocated on the heap (using 'new' operator), it must be caught through a pointer.


Why must? Why cannot it be accessed through reference? I mean, you catch what is thrown. So if you throw the object by dereferencing the pointer, you may catch it through reference. Isnt this correct?


Zdeslav Vojkovic wrote:
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).


I can see the complication, which doesnt exist in Java due to its automatic garbage collection.


Zdeslav Vojkovic wrote:
exceptions shoud be stack allocated, thrown, and caught by reference.


This is what puzzles me. If the exception is stack allocated, should we make sure the catch statement is in the same scope(braces) as that of the exception variable? Otherwise, how is the stack cleaned up when the control moves out of the scope?


Zdeslav Vojkovic wrote:
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


I see. What is the equivalent for the C++ "exception" class to free the object? Btw, this Delete method of CException might destroy the instance to free up resources, but is the object itself freed too (perhaps through 'delete this')?



thanks!
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 

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.