M
Marc
Hi all. Suppose we got something like this:
class A
{
//some code
};
class B: public SomeOtherClass, private A
{
//some more code
};
void foo (B* b)
{
A* a = dynamic_cast<A*> (b);
//a is NULL!?
}
When I use this code, dynamic_cast returns NULL. However, if I change B to
be a public inheritance from A, then it works fine. So, it seems like the
kind of inheritance is affecting dynamic_cast in some way. My question is:
is this correct according the C++ standard, or is it a bug in my compiler?
I'm using a pre-release version of g++ 3.3 (I know I shouldn't be using it,
but it's a long, non-related story).
class A
{
//some code
};
class B: public SomeOtherClass, private A
{
//some more code
};
void foo (B* b)
{
A* a = dynamic_cast<A*> (b);
//a is NULL!?
}
When I use this code, dynamic_cast returns NULL. However, if I change B to
be a public inheritance from A, then it works fine. So, it seems like the
kind of inheritance is affecting dynamic_cast in some way. My question is:
is this correct according the C++ standard, or is it a bug in my compiler?
I'm using a pre-release version of g++ 3.3 (I know I shouldn't be using it,
but it's a long, non-related story).