How to implement dynamic_cast?

"how would you implement dynamic_cast?". If you've never thought about it, then now is your time. Re-read John Philips' comments about polymorphism above, then see if you can implement a plain-vanilla one, then think about multiple inheritance, then toss in virtual inheritance. I got close during the interview, but didn't think about the implications of virtual inheritance. This was by far the hardest pure C++ question I've had in interview.