Click here to Skip to main content
15,930,117 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
led mike16-Aug-07 6:33
led mike16-Aug-07 6:33 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 6:42
Mark Salsbery16-Aug-07 6:42 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
led mike16-Aug-07 7:01
led mike16-Aug-07 7:01 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 7:05
Mark Salsbery16-Aug-07 7:05 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
led mike16-Aug-07 7:21
led mike16-Aug-07 7:21 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 7:31
Mark Salsbery16-Aug-07 7:31 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Gary R. Wheeler18-Aug-07 4:10
Gary R. Wheeler18-Aug-07 4:10 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery18-Aug-07 7:06
Mark Salsbery18-Aug-07 7:06 
Well, like I said, "can't" was the wrong word.

Whether one should or not - that's left up to the individual Smile | :)

I think in the case you've discussed, I'd add a constructor in the
derived class that takes a const reference to a base class object
as a parameter.  At least the "downcast" behavior is well defined that
way, and you don't have to use the questionable cast.
The CRect class in MFC is a good example of this.

Thanks for the discussion Smile | :)
Mark



Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 7:01
Mark Salsbery16-Aug-07 7:01 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Cyrilix16-Aug-07 7:03
Cyrilix16-Aug-07 7:03 
AnswerRe: Safely converting a base class ptr to a derived class ptr Pin
Gary R. Wheeler18-Aug-07 4:02
Gary R. Wheeler18-Aug-07 4:02 
Questiontoolbar in dialog based application Pin
sudheee16-Aug-07 4:43
sudheee16-Aug-07 4:43 
AnswerRe: toolbar in dialog based application Pin
James R. Twine16-Aug-07 4:48
James R. Twine16-Aug-07 4:48 
QuestionHow to know if a document is open/changed? Pin
PravinSingh16-Aug-07 4:29
PravinSingh16-Aug-07 4:29 
QuestionRe: How to know if a document is open/changed? Pin
David Crow16-Aug-07 4:37
David Crow16-Aug-07 4:37 
GeneralRe: How to know if a document is open/changed? Pin
PravinSingh16-Aug-07 4:43
PravinSingh16-Aug-07 4:43 
GeneralRe: How to know if a document is open/changed? Pin
led mike16-Aug-07 4:48
led mike16-Aug-07 4:48 
General[Message Deleted] Pin
sudheee16-Aug-07 6:19
sudheee16-Aug-07 6:19 
GeneralRe: How to know if a document is open/changed? Pin
led mike16-Aug-07 6:39
led mike16-Aug-07 6:39 
GeneralRe: How to know if a document is open/changed? Pin
David Crow16-Aug-07 7:22
David Crow16-Aug-07 7:22 
Questionproblem on "one or more breakpoints are not positioned on valid lines" Pin
cy163@hotmail.com16-Aug-07 4:04
cy163@hotmail.com16-Aug-07 4:04 
AnswerRe: problem on "one or more breakpoints are not positioned on valid lines" Pin
KarstenK16-Aug-07 4:23
mveKarstenK16-Aug-07 4:23 
AnswerRe: problem on "one or more breakpoints are not positioned on valid lines" Pin
David Crow16-Aug-07 4:40
David Crow16-Aug-07 4:40 
QuestionHow to retrieve font size of a dialog box?? Pin
vasmvr16-Aug-07 4:03
vasmvr16-Aug-07 4:03 
AnswerRe: How to retrieve font size of a dialog box?? Pin
ashukasama16-Aug-07 4:24
ashukasama16-Aug-07 4:24 

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.