Click here to Skip to main content
16,004,924 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 6:44
Mark Salsbery16-Aug-07 6:44 
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 
Mark Salsbery wrote:
Why would one derive a class and not add anything?


Simple. The member functions change from derivation to derivation. In that case, the base class defines the common data, and the member functions in the derived classes define the behavior. You can cast a base class to a derived one to choose behavior.

Note that I'm not advocating doing things this way. This requires that the code 'knows' that the cast is safe. Also, this kind of goes in the reverse direction of the virtual mechanism, which could lead to all sorts of subtle bugs if you combined the two Dead | X| .


Software Zen: delete this;

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 
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 

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.