In the followint code, how does the pointer conversion & multi-inheritance play together?
class Foo {
public:
virtual void someFunc();
};
class Bar;
void someWork(Bar *bar) {
((Foo*) bar)->someFunc();
}
class Bar: public Zed, public Foo {
...
virtual void someFunc() { ... do something else ... }
}
Bar bar;
int main() {
someWork(&bar);
}
My understanding is kinda shaky.
On one hand, someWork knows nothing about Bar, so this shouldn't work; but on the other hand, I have forward declared Bar.
Thanks!