Click here to Skip to main content
15,921,643 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: exception and global variable Pin
Rajesh R Subramanian27-Jan-08 23:34
professionalRajesh R Subramanian27-Jan-08 23:34 
GeneralRe: exception and global variable Pin
George_George27-Jan-08 23:38
George_George27-Jan-08 23:38 
JokeRe: exception and global variable Pin
CPallini27-Jan-08 23:47
mveCPallini27-Jan-08 23:47 
GeneralRe: exception and global variable Pin
George_George27-Jan-08 23:54
George_George27-Jan-08 23:54 
GeneralRe: exception and global variable Pin
Maxwell Chen27-Jan-08 23:57
Maxwell Chen27-Jan-08 23:57 
GeneralRe: exception and global variable Pin
Cedric Moonen27-Jan-08 23:13
Cedric Moonen27-Jan-08 23:13 
GeneralRe: exception and global variable Pin
George_George27-Jan-08 23:24
George_George27-Jan-08 23:24 
GeneralRe: exception and global variable Pin
Cedric Moonen27-Jan-08 23:34
Cedric Moonen27-Jan-08 23:34 
George_George wrote:
In the exception handler of constructor.


Sorry, but that doesn't make sense at all. By "users", I didn't mean real person that manipulate your program but part of your program that use your class. In that case, you would like to know that your object failed to construct so that you can take specific actions. The best way to do it is to throw an exception from within your constructor. Let's take an example:

// CDummyClass might throw an exception if it fails to construct<br />
void MyFunc<br />
{<br />
   try<br />
   {<br />
      CDummyClass test();<br />
      test.DoSomething();<br />
   }<br />
   catch (....)<br />
   {<br />
      // Ok CDummyClass failed to construct so we'll try something else.<br />
   }<br />
}


You cannot design all your classes so that they don't throw an exception in their constructor just because *somebody might be one day* using it as a global object.

And in general, in a specific object, you don't want to do something specific if an error occurs but let the user (part of the programm) manage the error in a specific way (because it knows how to handle the error).

Cédric Moonen
Software developer

Charting control [v1.2]

GeneralRe: exception and global variable Pin
George_George27-Jan-08 23:53
George_George27-Jan-08 23:53 
GeneralRe: exception and global variable Pin
Cedric Moonen28-Jan-08 0:05
Cedric Moonen28-Jan-08 0:05 
GeneralRe: exception and global variable Pin
George_George28-Jan-08 0:26
George_George28-Jan-08 0:26 
QuestionRe: exception and global variable Pin
David Crow28-Jan-08 5:08
David Crow28-Jan-08 5:08 
GeneralRe: exception and global variable Pin
George_George28-Jan-08 13:43
George_George28-Jan-08 13:43 
GeneralRe: exception and global variable Pin
David Crow28-Jan-08 15:58
David Crow28-Jan-08 15:58 
QuestionHow to access a single object from multiple thread Pin
Ranojay27-Jan-08 21:57
Ranojay27-Jan-08 21:57 
GeneralRe: How to access a single object from multiple thread Pin
Iain Clarke, Warrior Programmer27-Jan-08 22:02
Iain Clarke, Warrior Programmer27-Jan-08 22:02 
GeneralRe: How to access a single object from multiple thread Pin
Ranojay28-Jan-08 20:20
Ranojay28-Jan-08 20:20 
GeneralRe: How to access a single object from multiple thread Pin
Iain Clarke, Warrior Programmer28-Jan-08 21:50
Iain Clarke, Warrior Programmer28-Jan-08 21:50 
GeneralRe: How to access a single object from multiple thread Pin
Ranojay30-Jan-08 20:49
Ranojay30-Jan-08 20:49 
GeneralRe: How to access a single object from multiple thread Pin
Iain Clarke, Warrior Programmer30-Jan-08 21:57
Iain Clarke, Warrior Programmer30-Jan-08 21:57 
GeneralRe: How to access a single object from multiple thread Pin
Ranojay1-Feb-08 22:03
Ranojay1-Feb-08 22:03 
QuestionNetwork detection on windows 98 Pin
Somnath_Mali27-Jan-08 20:36
Somnath_Mali27-Jan-08 20:36 
QuestionRe: Network detection on windows 98 Pin
David Crow28-Jan-08 5:11
David Crow28-Jan-08 5:11 
Question"Show Desktop" windows event? Pin
Somnath_Mali27-Jan-08 20:31
Somnath_Mali27-Jan-08 20:31 
QuestionRe: "Show Desktop" windows event? Pin
David Crow28-Jan-08 5:13
David Crow28-Jan-08 5:13 

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.