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

C / C++ / MFC

 
GeneralPlease help me. Pin
dSolariuM18-Jan-05 20:34
dSolariuM18-Jan-05 20:34 
GeneralRe: Please help me. Pin
Yulianto.18-Jan-05 20:54
Yulianto.18-Jan-05 20:54 
GeneralRe: Please help me. Pin
pc_dev18-Jan-05 22:29
pc_dev18-Jan-05 22:29 
GeneralRe: Please help me. Pin
David Crow19-Jan-05 3:17
David Crow19-Jan-05 3:17 
GeneralError that occured only in Release mode Pin
Yaron Abershitz18-Jan-05 20:05
Yaron Abershitz18-Jan-05 20:05 
GeneralRe: Error that occured only in Release mode Pin
Yulianto.18-Jan-05 20:48
Yulianto.18-Jan-05 20:48 
GeneralGeneral C++ question on constructors Pin
melwyn18-Jan-05 19:33
melwyn18-Jan-05 19:33 
GeneralRe: General C++ question on constructors Pin
Emilio Garavaglia18-Jan-05 21:56
Emilio Garavaglia18-Jan-05 21:56 
May be the answer can change depending on compiler, but as far as I know, the constructor is called after memory allocation has occurred and its first instructions (think as executed at the "open brace") are "call the bases constructors and call the members constructors".
At that point the object can be assumed as effectively constructed and formed.

The problem is another: if your object is used as a base of another object and your constructor throws an exception ... The "other" object is not properly constructed. But the memory is allocated.
But the other object constructor cannot handle the exception as well, since it didn’t reach any possible "try/catch" block. (It escaped from its open brace)
In fact your exception escapes the constructors leaving the instantiator (the piece of program that asked to create the outer object) with an allocated, but partially constructed object.

The fact that "delete" can be properly called by the calling program, mostly depend on what constructors and destructors do.
Moral: avoid to throw exceptions in constructors... a "two phase construction" (by calling a separate "init" function after the construction) can be safer and give a more predictable behaviour.





2 bugs found.
> recompile ...
65534 bugs found.
D'Oh! | :doh:

GeneralRe: General C++ question on constructors Pin
markkuk19-Jan-05 2:02
markkuk19-Jan-05 2:02 
GeneralRe: General C++ question on constructors Pin
Mike Dimmick19-Jan-05 2:47
Mike Dimmick19-Jan-05 2:47 
QuestionGet FileName of a file if know position ?? Pin
Le Hong Anh18-Jan-05 19:33
Le Hong Anh18-Jan-05 19:33 
QuestionHow to integrate background color with button control Pin
phijophlip18-Jan-05 19:23
phijophlip18-Jan-05 19:23 
AnswerRe: How to integrate background color with button control Pin
Aamir Butt18-Jan-05 20:26
Aamir Butt18-Jan-05 20:26 
AnswerRe: How to integrate background color with button control Pin
Aamir Butt18-Jan-05 20:49
Aamir Butt18-Jan-05 20:49 
GeneralAutomated press and release of keys in Keyboard and GetKeyState of keyboard Pin
vidhyas18-Jan-05 19:00
vidhyas18-Jan-05 19:00 
Generalserial numer of the CD Pin
includeh1018-Jan-05 18:40
includeh1018-Jan-05 18:40 
GeneralRe: serial numer of the CD Pin
Dudi Avramov20-Jan-05 0:35
Dudi Avramov20-Jan-05 0:35 
QuestionHow can i change the background color of a button control in vc++ Pin
phijophlip18-Jan-05 17:24
phijophlip18-Jan-05 17:24 
AnswerRe: How can i change the background color of a button control in vc++ Pin
Selvam R18-Jan-05 18:09
professionalSelvam R18-Jan-05 18:09 
GeneralRe: How can i change the background color of a button control in vc++ Pin
ThatsAlok18-Jan-05 18:26
ThatsAlok18-Jan-05 18:26 
AnswerRe: How can i change the background color of a button control in vc++ Pin
ThatsAlok18-Jan-05 18:10
ThatsAlok18-Jan-05 18:10 
GeneralRe: How can i change the background color of a button control in vc++ Pin
Selvam R18-Jan-05 22:30
professionalSelvam R18-Jan-05 22:30 
Questionwhat is the use of this pointer ? Pin
phijophlip18-Jan-05 17:22
phijophlip18-Jan-05 17:22 
AnswerRe: what is the use of this pointer ? Pin
Selvam R18-Jan-05 18:08
professionalSelvam R18-Jan-05 18:08 
AnswerRe: what is the use of this pointer ? Pin
David Crow19-Jan-05 4:23
David Crow19-Jan-05 4:23 

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.