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

C / C++ / MFC

 
GeneralRe: "__declspec(thread)" or "__declspec(thread) static" Pin
chenggong16-Aug-07 9:14
chenggong16-Aug-07 9:14 
QuestionSafely converting a base class ptr to a derived class ptr Pin
Cyrilix16-Aug-07 4:56
Cyrilix16-Aug-07 4:56 
AnswerRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 5:06
Mark Salsbery16-Aug-07 5:06 
GeneralRe: Safely converting a base class ptr to a derived class ptr [modified] Pin
James R. Twine16-Aug-07 5:18
James R. Twine16-Aug-07 5:18 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 5:24
Mark Salsbery16-Aug-07 5:24 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
Mark Salsbery16-Aug-07 5:26
Mark Salsbery16-Aug-07 5:26 
GeneralRe: Safely converting a base class ptr to a derived class ptr Pin
James R. Twine16-Aug-07 5:28
James R. Twine16-Aug-07 5:28 
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 
I didn't look at MFC internals, but consider this scenario:
Base *pBase = new Child;
Child *pChild = (Child*)pBase;

What does the pChild refer to? I think a child, not a parent. (I didn't test it yet)
Now take a look at this:
CWnd* pWnd = new CEdit;
...
...
CEdit* pEdit = (CEdit*)GetDlgItem(EDIT_BX);

// And consider this function returns a pointer to that wnd
CWnd* GetDlgItem(UINT blah)
{
  return pWnd;
}

if they did something like this, we actually have a pointer to a child.

// "Life is very short and is very fragile also." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
}

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

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.