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. Class hierarchy question...

Class hierarchy question...

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 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.
  • V Offline
    V Offline
    vmaltsev
    wrote on last edited by
    #1

    Hail everyone, Let's say I have two classes, A and B, as well as two interface (abstract) classes for them, iA and iB. Class B derived from class A and interface iB, interface iB derived from iA, so we have, class iA { vitrual method AA } class A: public iA { method AA } class iB: public iA { vitrual method BB } class B: public A, public iB { method BB } By doing this I want to be able to access methods of class B (and A in it) through interface iB, but, I can't do so. Compiler justly says "pure vitual function AA was not defined in B" So, couls you please explain to me how this hierarchy should look like? Thanks in advance, any suggestion would be helpful.

    H 1 Reply Last reply
    0
    • V vmaltsev

      Hail everyone, Let's say I have two classes, A and B, as well as two interface (abstract) classes for them, iA and iB. Class B derived from class A and interface iB, interface iB derived from iA, so we have, class iA { vitrual method AA } class A: public iA { method AA } class iB: public iA { vitrual method BB } class B: public A, public iB { method BB } By doing this I want to be able to access methods of class B (and A in it) through interface iB, but, I can't do so. Compiler justly says "pure vitual function AA was not defined in B" So, couls you please explain to me how this hierarchy should look like? Thanks in advance, any suggestion would be helpful.

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Because class B inherits from both class A and class iB, it has to deal with two different vtables. Therefore you need to provide method AA of class iA in both vtables and that is the source of the error message: the implementation for class iB is missing. Just write a wrapper method AA in the class B, calling A::AA; this will redirect iB::AA to A::AA.


      "though nothing  will keep us together  we can beat them  for ever and ever" rechi

      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