Lets examine following case
struct A{
virtual ~A(){}
};
struct B : public A{
virtual ~B(){}
};
struct C : public B{
virtual ~C(){}
};
int main(){
A* a = new C();
B* b = dynamic_cast<B*>(a);
}
How does dynamic_cast know that B is a super class of C at the runtime. I understand that dynamic_cast accesses type_info of *a and finds that *a is actually of type C by examining name property. But how not having all the information that compilator has about classes inheritance does dynamic_cast know that B is a superclass of C having only information that the type of *a is C? Does that make any sense?