Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Multiple Inheritance?

Multiple Inheritance?

Scheduled Pinned Locked Moved C / C++ / MFC
c++oophelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peter Liddle
    wrote on last edited by
    #1

    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.

    T J 2 Replies Last reply
    0
    • P Peter Liddle

      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.

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      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?

      P 1 Reply Last reply
      0
      • P Peter Liddle

        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.

        J Offline
        J Offline
        Joaquin M Lopez Munoz
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • T Tomasz Sowinski

          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?

          P Offline
          P Offline
          Philippe Mori
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups