Multiple Inheritance?
-
Hey Guys I need some help with Multiple Inheritance in MFC like HOW THE HELL DO YOU DO IT?!?!?!? I would like to create a class derived from an MFC class say CView and a generic class i have written which is a standard class deriverd from nothing. I have done it and got it to compile but it will crash when MFC calls the ISKindOf statment.:confused: Any links to tutorials on this would be extremly useful.
-
Hey Guys I need some help with Multiple Inheritance in MFC like HOW THE HELL DO YOU DO IT?!?!?!? I would like to create a class derived from an MFC class say CView and a generic class i have written which is a standard class deriverd from nothing. I have done it and got it to compile but it will crash when MFC calls the ISKindOf statment.:confused: Any links to tutorials on this would be extremly useful.
MFC's RTTI (CObject::IsKindOf and friends) doesn't support multiple inheritance. You can get better results with C++ RTTI - dynamic_cast is the way to go. Tomasz Sowinski -- http://www.shooltz.com
- It's for protection
- Protection from what? Zee Germans? -
Hey Guys I need some help with Multiple Inheritance in MFC like HOW THE HELL DO YOU DO IT?!?!?!? I would like to create a class derived from an MFC class say CView and a generic class i have written which is a standard class deriverd from nothing. I have done it and got it to compile but it will crash when MFC calls the ISKindOf statment.:confused: Any links to tutorials on this would be extremly useful.
Is
IsKindOf
duplicated or something? If not, I see no reason why what you describe should fail. Some code would be most helpful. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
MFC's RTTI (CObject::IsKindOf and friends) doesn't support multiple inheritance. You can get better results with C++ RTTI - dynamic_cast is the way to go. Tomasz Sowinski -- http://www.shooltz.com
- It's for protection
- Protection from what? Zee Germans?MFC RTTI is older than standard C++ RTTI and is more limited and manual. If MFC does the call to IsKindOf when it crashes, then you may not ba able to replace it with C++ RTTI (dynamic_cast) as suggested in another reply. As an alternative, you may check your derivation order. Does your class first derives from the MFC class then from your class (which should probably not derives from CObject). If not, changing that may be a fix... It is possible that MFC RTTI rely on the fact that the derived class start at the same adress as the base class but I am not sure that there is such a restriction. It's just a guess. And does your class is properly defined for MFC RTTI uses? Maybe you should add some MFC macros in your derived class. I don't know... I think that it is optional as long as the information is not required. But maybe the problem is that the information is required by document templates to create the view. Philippe Mori