Re: Problem with multiple inheritance
You can turn on RTTI under project property-C/C++-Language-Enable Run-Time
Type Info.
I'm trying to think of a better way to design your classes, but I can't
really give you a good answer without knowing why you have designed them
they way that you have, and why they are not all inhereting from the same
class.
Why is class C a class that doesn't inherite from class A?
AliR.
"No_Name" <no_mail@no_mail.com> wrote in message
news:go167e$j0m$1@aioe.org...
AliR (VC++ MVP) a couch? sur son ?cran :
Things don't quite add up.
If InheritFromC is only in AB and ABC then how can you call it on a A *
object in your MyFunction without any casts?
Have you tried dynamic type casting? That might eliminate your problem.
(you have to turn on the RTTI compiler settings)
void MyFunction(A *myObject)
{
C *mySecondObject = dynamic_cast<C*>(myObject);
if (myObject != NULL)
{
mySecondObject->I_Am_From_C();
}
}
AliR.
You're right, I didn't specified that class A has InheritsFromC() function
too (in fact, it's a pure virtual function).
For the moment, when I try dynamic cast, I get a strabge behaviour from
Windows CE, as my program hangs but does not crash ...
I'll be looking in my project settings to know how I can turn on RTTI
settings ... (I never used that).
I thought multiple inheritance from A and C classes would allow me to
manage my object as if it was a A object or a C object ...