Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Issues with multiple inheritance
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Alexander Adam, post: 2771181"] Hi! I got a class structure similar to: class Base_Object { ... some functions ... } class Object: public Base_Object, public IDispatch { .. implementation of some Base_Object methods .. implementation of some IDispatch methods } class A : public virtual Object {} class B : public virtual Object {} class C : public A, public B {} Now the issue is this -- I need to get access to the right pointer of the base Object class. When doing this on class C, the returned result is wrong and the vTable of the returned "Object" class does point to some methods in C which is obviously wrong. I understand the paradigma of the "this" pointer and multiple inheritance and I know that I could downcast C to A, then downcast to Object and I'd get the right one. But I cannot and do not want to do this as my class hierarchy goes much further / deeper. The this example: class C : public A, public virtual B {} class D : public B, public C {} Now class D has several methods returning instances of D and C. Within D, I do not really know which kind of "C" it is, just that the returned class is inherited from C. All I want to do then is to get the correct "Object" class out of the returned "C" class so that I can access Object's methods correctly without using downcasting a few times. See, I do not really care which Object instance I get because the Object's methods are calling one virtual method of Base_Object class which each of the subclasses implemenents so it doesn't really matter. I hope my description got clear so far, I didn't find any kind of idea or solution to this issue eventhough having seeked the web for quite a while. The only solution was downcasting but I cannot do this for each class because I got hundreds of classes. Regards Alexander [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Issues with multiple inheritance
Top