By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,443 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,443 IT Pros & Developers. It's quick & easy.

multiple inheritance - vtable issue

P: n/a
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
Oct 27 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Anuj P Shah wrote:
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


Please post a complete but minimal code sample that demonstrates the
problem. See the FAQ for guidelines:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Cheers! --M

Oct 27 '05 #2

P: n/a
TIT
Anuj P Shah sade:
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.
What function calls? malloc()?
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?


Yes, the symptoms! Uh?
Ah, you mean that you blame the vtable for your corrupt code?

TIT
Oct 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.