overriding mfc inheritance
Here is the MFC class hierachy:
CObject
|
CCmdTarget
|
CWnd
|
CDialog
|
CPropertyPage
Will I be able to do something like this ? :
CObject
|
CCmdTarget
|
CWnd
|
SDialog
|
CPropertyPage
My SDialog derives from CDialog.
My SDialog has functionality that I want to be able to use in my class (CMyPropertyPage) that I will derive from CPropertyPage....
One obvious approach is to use multiple inheritance:
CMyPropertyPage : public CPropertyPage, public SDialog
{
}
Thanks,
MD
Re: overriding mfc inheritance
Multiple inheritance is strongly discouraged with MFC - especially when deriving from two classes which are both derived from CWnd as in your case - this won't work anyway.
You should probably implement the functionality you need in a class derived from CPropertyPage. If you absolutely need to share some part of the implementation for both CDialog- and CPropertyPage-derived classes, you could still consider creating a mix-in class with that behaviour (however, that class must nor be derived from CWnd or any other MFC class like CObject). You could then use multiple inheritance, deriving CYourDialog from CDialog and the mix-in class, and CYourPropertyPage from CPropertyPage and the mix-in class.
Re: Re: overriding mfc inheritance
Quote:
Originally posted by gstercken
Multiple inheritance is strongly discouraged with MFC - especially when deriving from two classes which are both derived from CWnd as in your case - this won't work anyway.
Just out of curiosity...do you happen to know whether this includes virtual derivation as well?
Re: Re: Re: overriding mfc inheritance
Quote:
Originally posted by Andreas Masur
Just out of curiosity...do you happen to know whether this includes virtual derivation as well?
Yes, even virtual derivation will not solve all the problems which arise when multiply deriving from certain MFC classes. From MSDN, TN016:
Quote:
You may ask, "If you inherit CObject virtually, won't all of the ambiguity problems go away?".
[...]
The real answer is no, virtual inheritance will not solve the ambiguity problems illustrated above. For example: the Dump virtual member function is still ambiguous (since CFrameWnd and CObList implement it differently).
Re: Re: Re: Re: overriding mfc inheritance
Quote:
Originally posted by gstercken
Yes, even virtual derivation will not solve all the problems which arise when multiply deriving from certain MFC classes.
Sorry for the late reply...but thank you very much for the information...