Click here to Skip to main content
15,844,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: My Sql Connectiom Pin
MsmVc3-Jul-09 22:16
MsmVc3-Jul-09 22:16 
AnswerRe: My Sql Connectiom Pin
Stuart Dootson4-Jul-09 0:22
professionalStuart Dootson4-Jul-09 0:22 
Questionhide a dialog on task bar. Pin
chandu0043-Jul-09 20:12
chandu0043-Jul-09 20:12 
AnswerRe: hide a dialog on task bar. Pin
enhzflep3-Jul-09 20:30
enhzflep3-Jul-09 20:30 
QuestionSend values from Exe to Browser Pin
tgm.arjun093-Jul-09 17:59
tgm.arjun093-Jul-09 17:59 
AnswerRe: Send values from Exe to Browser Pin
David Crow3-Jul-09 18:35
David Crow3-Jul-09 18:35 
AnswerRe: Send values from Exe to Browser Pin
Hamid_RT4-Jul-09 1:00
Hamid_RT4-Jul-09 1:00 
QuestionConstructor Exception Pin
hpjchobbes3-Jul-09 10:08
hpjchobbes3-Jul-09 10:08 
I'm still new to learning C++ (learned some of C# first) and having a hard time knowing what the preferred way to handle this situation is.

I have a class that has a constructor that does some initialization work. If this initialization fails, I want to inform the program that this is not a valid object to use. I created my constructor to throw an exception as that is really the only way that I know how (since constructors can't return values).

Now, in my program I am trying to create an object of my class so I put a try/catch block around it. This worked great until I realized that no code outside of the try/catch block would be able to use that object because it is out of scope.

It appears that there is no good way to use global variables that has a constructor that throws an exception. So what is the normal procedure for this type of situation. Do you normally create a pointer to the object so that you can use the new keyword to create the object? If so, is there a way to prevent someone from creating an object and not a point to your class?
AnswerRe: Constructor Exception Pin
Stuart Dootson3-Jul-09 10:26
professionalStuart Dootson3-Jul-09 10:26 
QuestionIE automation [modified] Pin
eoloe3-Jul-09 9:08
eoloe3-Jul-09 9:08 
AnswerRe: IE automation Pin
Stuart Dootson3-Jul-09 9:47
professionalStuart Dootson3-Jul-09 9:47 
Questionsimple template question Pin
minkowski3-Jul-09 7:53
minkowski3-Jul-09 7:53 
QuestionRe: simple template question Pin
CPallini3-Jul-09 8:56
mveCPallini3-Jul-09 8:56 
AnswerRe: simple template question Pin
Stuart Dootson3-Jul-09 9:39
professionalStuart Dootson3-Jul-09 9:39 
QuestionSockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 6:07
Manmohan293-Jul-09 6:07 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
«_Superman_»3-Jul-09 6:10
professional«_Superman_»3-Jul-09 6:10 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 6:31
professionalStuart Dootson3-Jul-09 6:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:10
Manmohan293-Jul-09 10:10 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:21
professionalStuart Dootson3-Jul-09 10:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:39
Manmohan293-Jul-09 10:39 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:53
professionalStuart Dootson3-Jul-09 10:53 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 11:21
Manmohan293-Jul-09 11:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 11:28
professionalStuart Dootson3-Jul-09 11:28 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 11:31
professionalStuart Dootson3-Jul-09 11:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 11:48
Manmohan293-Jul-09 11:48 

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.