A
Anuj P Shah
Hi,
I am using multiple implementation inheritance in one of my designs, and it
seems i am having some kind of a vtable problem when accessing functions.
The problem is like so:
class E inherits from class C and D, and C inherits from B, A. Another
class F stores pointers to instances of type A in a STL map. Now I am
storing pointers to type E in F (automatic upcasting). Another class G uses
F to get the pointers of class E and use them for making certain function
calls. My problem is that I am not able to use the pointer for any function
calls; there is a runtime error (an access violation). There is no
compilation error. But the debug window is able to resolve the pointer
without problems. I can static_cast the pointer into other types in the
hierarcy and get the pointers for those other types, but again there is a
runtime error when accessing them. I tried dynamic_cast but it failed at
runtime. If I use class qualifier when accessing a function using the
pointer, there is no error. Ofcourse that is not useful, because then I
have no advantage of the class heirarchy (polymorphism). These symptoms
make me think that the vtable has some kind of screw up or confusion. Can
anybody guess, what might be the sources of this problem?
Thanks,
Anuj
I am using multiple implementation inheritance in one of my designs, and it
seems i am having some kind of a vtable problem when accessing functions.
The problem is like so:
class E inherits from class C and D, and C inherits from B, A. Another
class F stores pointers to instances of type A in a STL map. Now I am
storing pointers to type E in F (automatic upcasting). Another class G uses
F to get the pointers of class E and use them for making certain function
calls. My problem is that I am not able to use the pointer for any function
calls; there is a runtime error (an access violation). There is no
compilation error. But the debug window is able to resolve the pointer
without problems. I can static_cast the pointer into other types in the
hierarcy and get the pointers for those other types, but again there is a
runtime error when accessing them. I tried dynamic_cast but it failed at
runtime. If I use class qualifier when accessing a function using the
pointer, there is no error. Ofcourse that is not useful, because then I
have no advantage of the class heirarchy (polymorphism). These symptoms
make me think that the vtable has some kind of screw up or confusion. Can
anybody guess, what might be the sources of this problem?
Thanks,
Anuj