Class hierarchy question...
-
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.
-
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.
Because
class B
inherits from bothclass A
andclass iB
, it has to deal with two different vtables. Therefore you need to providemethod AA
ofclass iA
in both vtables and that is the source of the error message: the implementation forclass iB
is missing. Just write a wrappermethod AA
in theclass B
, callingA
::AA
; this will redirectiB
::AA
toA
::AA
.
"though nothing will keep us together we can beat them for ever and ever" rechi