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

C / C++ / MFC

 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Hamed Musavi16-Aug-07 6:16
Hamed Musavi16-Aug-07 6:16 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
James R. Twine16-Aug-07 7:07
James R. Twine16-Aug-07 7:07 
GeneralRe: Safely converting a base class ptr to a derived class ptr [modified] Pin
Hamed Musavi16-Aug-07 7:27
Hamed Musavi16-Aug-07 7:27 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Maxwell Chen16-Aug-07 6:26
Maxwell Chen16-Aug-07 6:26 
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 
Mark Salsbery wrote:
IMO it's a really bad idea.

Yes, as I stated. I have used it to deal with MFC issues in the past. I have never designed it into my own classes.

Mark Salsbery wrote:
Why would one derive a class and not add anything? Even a virtual function
override is going to add to the class.

Notice that the virtual override does NOT work (goes to foo) making this a very tenuous situation, but under certain conditions...
class foo
{
    int n;
public:
    foo(int v){n=v;}
    virtual void dump(){cout << "foo: " << n << endl; }
};

class bar : public foo
{
public:
    virtual void dump(){cout << "bar: "; dump();}
    void dumpex(){cout << "bar: "; dump();}
};

    foo* f = new foo(12);
    bar* mybar = reinterpret_cast<bar*>(f);
    mybar->dump();
    mybar->dumpex();




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

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.