Derived class linker - is this wrong?

Posted by bobobobo on Stack Overflow See other posts from Stack Overflow or by bobobobo
Published on 2010-03-18T13:54:34Z Indexed on 2010/03/18 14:01 UTC
Read the original article Hit count: 598

We have this situation:


                    A  B
                    ^  ^
                    | /
                    C

so

class A { }
class B { }
class C : public A, public B { }

Now, B wants to access a property in C.

How do you do this?

The solution I came up with is to place a pointer in B to an instance of C, which is only active (not null) if this B is in fact a C.

© Stack Overflow or respective owner

Related posts about inheritance

Related posts about language-agnostic