
Originally Posted by
Pix
struct D : public B1, public B2 // do I need the "public"?
Technically, no, not for structures, but IMO it's best to state it explicitely anyway.
funcb2 needs the value of i. What's a good way to get it out of B1?
Depends. Where are you calling funcb2 from? If the only call into the function is from Struct D, you could just pass it as a parameter of the function.
Otherwise there is no relationship between your two base classes. Just because they are both a parent of D doesn't mean they can share member data, unless you provide some specific functionality for that (or pass it in through the derived class).
Is it possible for you to do this?
struct B1 {};
struct B2 : public B1 {};
struct D : public B2 {};
That would give you i inside of B2 where your funcb2() lives. Plus, then you don't have multiple inheretance issues to worry about.
"They laughed when I said I was going to be a comedian ... They're not laughing now." - Bob Monkhouse