static_cast vs dynamic_cast
问题 Suppose I'm given a C++ library full of inheritance. I'm given a Base* in a function when I know that it is actually pointing to a Derived object and Derived inherits Base . But I don't know what kind of inheritance it is (public/protected/private). I also don't know if there is any virtual function in the hierarchy. Given this situation, without looking into the source code/documentation of Base and Derived , which cast should I use? Or should I consult the code/documentation first to ensure