Click here to Skip to main content
15,889,595 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwhere should add the try-catch? Pin
yu-jian13-May-12 5:55
yu-jian13-May-12 5:55 
AnswerRe: where should add the try-catch? Pin
Richard MacCutchan13-May-12 6:45
mveRichard MacCutchan13-May-12 6:45 
GeneralRe: where should add the try-catch? Pin
yu-jian13-May-12 18:39
yu-jian13-May-12 18:39 
AnswerRe: where should add the try-catch? Pin
ThatsAlok13-May-12 20:08
ThatsAlok13-May-12 20:08 
GeneralRe: where should add the try-catch? Pin
Richard MacCutchan13-May-12 21:41
mveRichard MacCutchan13-May-12 21:41 
AnswerRe: where should add the try-catch? Pin
TinyDevices13-May-12 20:59
professionalTinyDevices13-May-12 20:59 
GeneralRe: where should add the try-catch? Pin
yu-jian13-May-12 22:24
yu-jian13-May-12 22:24 
AnswerRe: where should add the try-catch? Pin
Aescleal14-May-12 3:15
Aescleal14-May-12 3:15 
I'm going to go contrary to Richard's advice here...

With a few exceptions (pardon the pun) exceptions in C++ should only be thrown when your code's going down in flames and there's no chance of recovery. This means that the only place you catch exceptions is around main. This means that your program dies cleanly after telling the user and programmer what's going on and releasing all its resources.

Having said that not everyone follows those rules. If you know a subsystem chucks exceptions out instead of error codes then write an exception eating wrapper around the subsystem and convert the exceptions to return codes.

Another place you have to use exceptions is around call backs into the OS. Don't let an exception fall into a OS hole or it may be fatal to the called app. This includes thread functions and window procedures.

Cheers,

Ash
QuestionNeed Help with Audio Output in C/C++ Pin
Veeshal Beotra13-May-12 4:12
Veeshal Beotra13-May-12 4:12 
AnswerRe: Need Help with Audio Output in C/C++ Pin
Vaclav_14-May-12 8:35
Vaclav_14-May-12 8:35 
QuestionChanging the background color of Text control or combo box when text got changed Pin
Ashish Ranjan Mishra13-May-12 4:01
Ashish Ranjan Mishra13-May-12 4:01 
AnswerRe: Changing the background color of Text control or combo box when text got changed Pin
«_Superman_»13-May-12 4:12
professional«_Superman_»13-May-12 4:12 
Question'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 20:44
AmbiguousName12-May-12 20:44 
QuestionRe: 'Forward Class Declaration' Not Working Pin
«_Superman_»12-May-12 20:53
professional«_Superman_»12-May-12 20:53 
AnswerRe: 'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 22:23
AmbiguousName12-May-12 22:23 
AnswerRe: 'Forward Class Declaration' Not Working Pin
Richard MacCutchan12-May-12 21:30
mveRichard MacCutchan12-May-12 21:30 
GeneralRe: 'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 22:29
AmbiguousName12-May-12 22:29 
GeneralRe: 'Forward Class Declaration' Not Working Pin
Richard MacCutchan12-May-12 22:34
mveRichard MacCutchan12-May-12 22:34 
AnswerRe: 'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 22:56
AmbiguousName12-May-12 22:56 
GeneralRe: 'Forward Class Declaration' Not Working Pin
Richard MacCutchan13-May-12 1:18
mveRichard MacCutchan13-May-12 1:18 
AnswerRe: 'Forward Class Declaration' Not Working Pin
krmed13-May-12 3:34
krmed13-May-12 3:34 
GeneralRe: 'Forward Class Declaration' Not Working Pin
Richard MacCutchan13-May-12 5:04
mveRichard MacCutchan13-May-12 5:04 
GeneralRe: 'Forward Class Declaration' Not Working Pin
AmbiguousName13-May-12 6:59
AmbiguousName13-May-12 6:59 
QuestionSubclass Procedure failed for edit control Pin
vishalgpt12-May-12 3:09
vishalgpt12-May-12 3:09 
AnswerRe: Subclass Procedure failed for edit control Pin
«_Superman_»12-May-12 4:25
professional«_Superman_»12-May-12 4:25 

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.