I think i'm pretty clear about their usage now.
But what I'm wondering is that how dynamic_cast can know the type info at runtime. what is it's runtime scheme?
the problem is, if you have a
const char* p = "hello"+1;
how can typeid(p) work? how does it know where to get the type info? p should definitely points to 'e' in this case.
I could guess some additional bytes were allocated at that memory address which are RTTI related, for example, these bytes could point to some global type table
faint!
I should have searched csdn first.
seems static_cast supports downcast, but not stupidcast.
if A is not super type of B, B is not super type of A,
then it fails.
but does anybody know how dynamic_cast get the type info?